当前位置:网站首页>Redis Express
Redis Express
2022-07-23 08:39:00 【HHachiman】
data type
String( character string )
- redis Of string Can contain any data , such as jpg Picture or serialized object
- string The type is Redis Basic data types ,string The maximum value of type can store 512MB
// Common commands
set key value // Definition
get key // obtain
// Cover key The value after the specified position of the stored string
// It is worth noting that this operation will not refresh the string life cycle , It's an updated method
SETRANGE KEY_NAME OFFSET( Location ) VALUE( value )
// Get string length
STRLEN KEY_NAME
Hash( Hash )
- Redis hash It's a key value (key=>value) The collection , He will be value Further divided into field And value Two parts , So as to carry out CURD
// Define and get
hset key name1 value1 name2 value2
hget key name1 // Get the first value
hget key name2 // Take the second value
// To judge the existence of
HEXISTS KEY_NAME FIELD_NAME // The return is bool value
// Get the value in the hash table
HGETALL KEY_NAME // The return is key value Staggered array
// Get the number of fields in the hash table , That is, there are several key value pairs
HLEN KEY_NAME
//Redis HSCAN The command is used to iterate over key value pairs in the hash table , Often used in fuzzy search
HSCAN key cursor [MATCH pattern] [COUNT count]
// But because the cursor will change after each search , One solution is to COUNT Then specify how many to return , Or direct violence gives a larger value
// The problem is that duplicate elements will be returned , So we need a reprocess
// Example , To realize fuzzy search ,$search for instance * high * Count *
hscan laravel_database 0 match $search count 1000

( The graph is Another Redis Visualization software example )
List( list )
- Sort by insertion order . You can add an element to the head of the list ( On the left L) Or tail ( On the right R), It's similar to a linked list file
// Deposit in
LPUSH runoobkey redis
// obtain
LRANGE runoobkey start stop
// remove
LERM key count value
// Scope delete
LTRIM KEY_NAME START STOP
// List length
LLEN KEY_NAME

Set( aggregate )
- Redis Of Set yes string Unordered collection of type , Element is not repeatable , Quick search
- My usage scenario is based on the preferences of computing users , Browse volume , The amount of collections, etc. will be recommended by all users for videos and articles , Use redis The intersection of sets
// Definition
SADD key value
// obtain
SMEMBERS key
// Number
SCARD KEY_NAME
// set intersection
SINTER KEY KEY1..KEYN
// Take the intersection and store it in DESTINATION_KEY in
SINTERSTORE DESTINATION_KEY KEY KEY1..KEYN
// Gather all the elements
SMEMBERS key
// Take difference
SDIFF FIRST_KEY OTHER_KEY1..OTHER_KEYN
// To differentiate and store
SDIFFSTORE DESTINATION_KEY KEY1..KEYN
// Remove Members
SREM KEY MEMBER1..MEMBERN
zset(sorted set Ordered set )
Sortable , Element is not repeatable , Quick query , be relative to set One more serial number , Command and set be similar
All rankings are in ascending order by default
Publish subscribe
- And advanced Stream
- Unfortunately, I haven't actually fought yet redis This function
SUBSCRIBE channel // Bloggers subscribe to channels
PUBLISH channel " Published content " // Users receive published content
Business
- Bulk operation is sending EXEC command Before being put into the queue cache .
- received EXEC command Then enter transaction execution , Transaction Arbitrary command execution failed , The rest of the orders are still being carried out .
- In the transaction execution process , Command requests submitted by other clients will not be inserted into the transaction execution command sequence .
MULTI // Start a transaction
...
EXEC // perform
Other commands
keys Check the matching template key,key Multiple time searches are slow and occupy threads , It is not recommended to use
del Delete specified key, It can be more than one , The number of deleted items is returned
exists Judge whether it exists
expire to key Set expiration date
expire key <time(s)>ttl see key Remaining time among -1 It's permanent ,-2 It doesn't exist
Key Hierarchical structure
- Multiple words are allowed to form a hierarchy , use “:” separate , Form a folder like structure , It will be particularly clear in the visual interface
- for example :

Cache actual use
- Cache optimization search speed implementation architecture diagram

- What needs attention is the problem of data consistency , In every design to CURD Pay attention to all places mysql and redis The consistency of
边栏推荐
- What is NFT? You don't know yet!
- 小程序商城如何精细化运营会员?
- 坚持陪同学习
- BufferedInputStream缓冲区填充问题
- Three cache strategies: cache side strategy, read/write through strategy, and write back strategy
- Send benefits again! Calendar applet source code
- Data analysis and privacy security become the key factors for the success or failure of Web3.0. How do enterprises layout?
- odbc excel--2022-07-21
- 【GNN报告】香港科技大学李佳:图异常检测再思考—我们究竟需要怎样的图神经网络?
- SSH password free login configuration
猜你喜欢

outlook客户端 outlook.com邮箱设置方法

I can't be angry with "voluntary salary reduction". I'm naked. I'm three times in four days. How can it end like this?

【GNN报告】香港科技大学李佳:图异常检测再思考—我们究竟需要怎样的图神经网络?

【JS 逆向百例】某公共资源交易网,公告 URL 参数逆向分析

Go concurrent programming basics: what is context

浅谈——网路安全架构设计(一)

Intel raid simulator Download

Redis profile

浅谈——网络安全架构设计(二)

数据分析与隐私安全成 Web3.0 成败关键因素,企业如何布局?
随机推荐
synchronized是如何實現的
不同where条件合并输出
Day011 循环结构中的跳转语句
XMODEM, ymodem and zmodem protocols are the three most commonly used communication protocols
Redis profile
坚持陪同学习
程序员可能还是程序员,码农可能只能是码农了
构造函数的初始化、清理及const修饰成员函数
Cases on classes and objects
全能链接(1) : 综合
“蔚来杯“2022牛客暑期多校训练营1
Redistemplate pipeline use
【JS 逆向百例】某公共资源交易网,公告 URL 参数逆向分析
程序环境和预处理
Flick enables mapstate to implement keyedstate
第三章 栈
创业文档:催款函怎么写
go gin : 多文件上传
Promise (II)
黑马程序员-接口测试-四天学习接口测试-第二天-接口用例设计,测试点,功能测试,安全测试,性能测试,单接口测试,业务场景测试用例,postman简介,安装