当前位置:网站首页>Linux server development, detailed explanation of redis related commands and their principles
Linux server development, detailed explanation of redis related commands and their principles
2022-07-07 07:55:00 【Tuen Mun pheasant calls me chicken】
Recommend a free open course of zero sound College , Personally, I think the teacher spoke well , Share with you :Linux,Nginx,ZeroMQ,MySQL,Redis,fastdfs,MongoDB,ZK, Streaming media ,CDN,P2P,K8S,Docker,TCP/IP, coroutines ,DPDK Etc , Learn now
MySql use B+ Tree organization data structure , and redis use dictionary Way to organize data structures .
command
- lpush liststr Mark Darren King King
- lrange liststr 0 -1 // It means from the first to the last
- set sayid 1000
- incr sayid
- incrby key 100
- decrby key 100
- setnx feng - // No, set successfully
- object encoding Mark
- setbit xxxx 9 1
application
- Record the number of likes of friends , Comments and hits .(hash)
- Record the circle of friends and talk about the list ( Sort ), Easy to display on the list page .(hash)
- Record the title of the article , Abstract , Sitting and cover , For list page display .(hash)
- Record the likes of users in the circle of friends ID list , Comment on ID list , For display and weight removal technology .(zset)
- Caching hot data , Reduce database pressure .(hash)
- If the circle of friends say ID Is an integer ID, have access to redis Let's allocate a circle of friends and talk about ID( Counter ).(string)
- Through set (set) Call and search set operation to record friends .(set)
string
set role:10001 ‘{[name]=“mark”,[age]=‘18’,[sex]=male}’
// Little change
//role:10001:recharge:10001
Distributed lock
- redis The implementation is an unfair lock , Block waiting
- setnx lock 1
- set lock uuid nx ex 30
- del lock
An operation
- setbit sign:10001:202106 1 1
- bitcount sign:10001:202106
- getbit sign:10001:202106 2
list
- LPUSH key value value value
- LPOP key
- LRANGE key start end
- LREM key count value
- BRPOP key timeout // Key features , The empty one is blocked here 0 For permanent blocking
- LTRIM say 0 49 // Get the leftmost 50 individual
- LRANGE say 0 49
hash
- HINCRBY key field increment
- HLEN key
set
- Disordered storage , Intersection and difference need to be sorted
- SADD key value1 value2 value3
- SMENBERS key
- SINSMENBER key value1
- SRANDMEMBER key 2 // Random access 2 individual
- SPOP key 1 // Kick one randomly
- SIDFF key
- SINTER key
- SUNION key
zset
- ZADD rank 100 MARK
- ZINCRBY rank 20 MARK
- ZCARD rank
- ZRANGE rank 80 100 byscore
- ZRANGE rank 80 100 byscore withscore
- ZREVRANGE rank 80 100 byscore withscore
Typical applications : Ranking List
边栏推荐
- The configuration that needs to be modified when switching between high and low versions of MySQL 5-8 (take aicode as an example here)
- Shell 脚本的替换功能实现
- Numbers that appear only once
- [webrtc] m98 Screen and Window Collection
- 【webrtc】m98 screen和window采集
- SQL优化的魅力!从 30248s 到 0.001s
- LeetCode 90:子集 II
- 有 Docker 谁还在自己本地安装 Mysql ?
- [Matlab] Simulink 自定义函数中的矩阵乘法工作不正常时可以使用模块库中的矩阵乘法模块代替
- Leetcode 90: subset II
猜你喜欢
【斯坦福计网CS144项目】Lab3: TCPSender
自定义类加载器加载网络Class
[webrtc] M98 screen and window acquisition
QT learning 28 toolbar in the main window
Linux server development, SQL statements, indexes, views, stored procedures, triggers
Detailed explanation of uboot image generation process of Hisilicon chip (hi3516dv300)
SQL优化的魅力!从 30248s 到 0.001s
json 数据展平pd.json_normalize
php导出百万数据
[webrtc] m98 Screen and Window Collection
随机推荐
解决问题:Unable to connect to Redis
2022 tea master (intermediate) examination questions and mock examination
今日现货白银操作建议
[mathematical notes] radian
图解GPT3的工作原理
QT learning 28 toolbar in the main window
Jenkins remote build project timeout problem
为什么要了解现货黄金走势?
vus.SSR在asynData函数中请求数据的注意事项
nacos
[performance pressure test] how to do a good job of performance pressure test?
《动手学深度学习》(四) -- 卷积神经网络 CNN
php导出百万数据
自定义类加载器加载网络Class
Live online system source code, using valueanimator to achieve view zoom in and out animation effect
Tongda injection 0day
You Li takes you to talk about C language 6 (common keywords)
Use and analysis of dot function in numpy
[VHDL parallel statement execution]
Live broadcast platform source code, foldable menu bar