当前位置:网站首页>Crazy God redis notes 09
Crazy God redis notes 09
2022-07-24 05:05:00 【Matcha flavored watermelon juice】

Open transaction multi:
Order to join the team is to write other normal orders
Execute transaction is exec
Normal execution of business !

Give up the business :
Every time we finish our business , You need to restart the transaction next time you want to use it :
Compiler exception ( Something is wrong with the code ! There was a mistake in the order !) All commands in the transaction will not be executed !

Runtime exception (1/0), If there are syntax errors in the transaction queue , So when you execute an order , Other commands can be executed normally , An error command throws an exception !
monitor !

Monitoring test :

We watch our money, The normal execution success is like this .
Testing multithreaded modification values , Use watch Can be regarded as redis Optimistic lock operation of !
Let's open another server
Our threads 2 Take out 10 block , The transaction has not been executed .
At this point, the thread 1 Recharge the balance to 1000 了 :

Before we execute , Another transaction modifies the value , Our implementation failed !
Can we solve this problem ?

If the modification fails , Just get the latest value .
unwatch: If transaction execution fails , Just unlock it first .
watch: Get the latest value , Watch again ,select version
exec: Compare whether the monitored value has changed , If there is no change , Then it can be executed successfully , If you change, the implementation fails . Just repeat this operation .
During the interview redis Often ask optimistic lock .

Let's create a java Empty item :
Create a module.
First we need to import our jedis My bag :

Coding test :
Connect to database
Operation command
disconnect
We started our local redis:
frequently-used Api Let's just take a look at it directly. It's almost the same as the previous order :
I won't write my own code here , Direct screenshot of crazy God's code .
Let's use jedis Do a normal thing :

We have a residue here, but we haven't emptied the cache .
We add flushdb:
We can use our... Now java To do all of us redis The function of . Next class we will go to springboot To integrate our redis.
边栏推荐
- 利用a*启发式搜索解决迷宫寻路问题
- 招聘| 嵌入式軟件(单片机)工程师
- Kingbase V8R6集群安装部署案例---脚本在线一键扩容
- Baidu wallet helps you repay the inter-bank repayment of your credit card. The handling fee is 0. Newcomers who arrive in real time will be rewarded with 5 yuan
- XML schema
- PHP修改配置文件的两种方法
- Introduction and use of pycharm debugging function
- All sections need to be able to have a problem system port, the first subscript. Many machines become
- Airiot Q & A issue 5 | how to use low code business flow engine?
- Add.Eslinctrc.js under SRC for the general format of the project
猜你喜欢

The difference between run and start in thread class

Threejs+shader drawing commonly used graphics

Airiot Q & A issue 5 | how to use low code business flow engine?

Middle aged crisis, workplace dad who dare not leave, how to face life's hesitation

打印1000年到2000年之间的闰年
![[postgraduate entrance examination vocabulary training camp] day 10 - capital, expand, force, adapt, depand](/img/9a/a218c46806cf286f0518a72809e084.png)
[postgraduate entrance examination vocabulary training camp] day 10 - capital, expand, force, adapt, depand

Forward proxy, reverse proxy and XFF

How much do you know about thread pool and its application

mapreduce概念

Event extraction and documentation (2020-2021)
随机推荐
How to register and apply for free for Apple Developer account in order to enjoy the upgrade experience at the first time
postgresql:在Docker中运行PostgreSQL + pgAdmin 4
。单类型数字传感一个应用程.0。 Up- 开址在出厂
Hcde city closed door meeting successfully held in Nanjing station
Smart pointer, lvalue reference, lvalue reference, lambda expression
Image painting for irregular holes using partial revolutions paper notes
Context encoders: feature learning by painting paper notes
The x-fkgom supporting the GOM engine key.lic is authorized to start
Xiaohongshu joins hands with HMS core to enjoy HD vision and grow grass for a better life
MapReduce concept
Hanoi problem
项目普遍格式问题 src下添加 .eslinctrc.js
Kingbase v8r6 cluster installation and deployment case - script online one click expansion
Chapter III encog workbench
Chapter 0 Introduction to encog
力。操处于业务低峰期。进口调用会帮您准备时,每个字
12306 the most wonderful verification code in history: normal users can easily identify the ticket grabbing software and are rejected
Chapter 1 regression, classification & clustering
JMeter record the BeanShell written into excel instance caused by an automatic data generation
How to make yourself look young in how old robot? How old do I look? Younger method skills