当前位置:网站首页>Redis common commands
Redis common commands
2022-07-07 09:20:00 【Wow, it's a small dish】
Other operating
- select 0 Select the first 0 A database
- randamkey Get random key, For example, three key:key1,key2,key3, Will return these three randomly key One of them
- move myString 1 Put the current database key Move to a database , The target library has , You can't move
- type key Returns the current key Of value type , May be string,list etc.
- keys * Returns all current key
- del key1 Delete key1
- exists key Judge whether it exists key 0 Why not 1 be for the purpose of
- expire key1 10 Set up key1 Expires in ten seconds
- pexpire key1 5000 Set up key1 Expire in five seconds
- persist key1 Delete expiration time
string
- set key1 value1 ex 10 Set up key1 And the value ,10 It will expire in seconds
- set key value Set up key and value
- get key obtain key Of value
- getrange key1 0 -1 Intercepting string , Including head and tail , from 0 Start
- getset key1 newvalue Set and return the old value
- mset key1 value1 key2 value2 key3 value3 Batch settings key and value Value
- mget key1 key2 key3 Batch acquisition key1 key2 key3 Value
- setnx key value Insert if it doesn't exist (not exists) return 0 or 1, Represents the success or failure of the operation
- set key value nx Insert if it doesn't exist return value
- set key value xx Must exist before inserting , Returns the inserted value
- setrange key index value from index Start replacing value , Return string length
- incr key Increasing key
- incrby key2 10 to key2 Increasing 10
- decr key2 key2 Decline 1
- decrby key2 5 key2 Decline 5
- incrbyfloat key3 0.5/-0.5 Floating point number increase or decrease
- append key tail Additional
- strlen key return key The length of
hash
- hset hashname key1 value Go to hashname Of hash To add a key-value pair
- hget hashname key1 obtain hashname in key Of value
- hmset hashname key1 value1 key2 value2 Set key value pairs in batch
- hmget hashname key1 key2 Batch fetch value
- hgetall hashname Get all key value
- hexists hashname key1 Judge key Whether there is return 0,1
- hsetnx hashname keynx value Set nonexistent key
- hincrby hashname key1 10/-2 Set up key1 Increasing 10
- hdel hashname key Delete key
- hkeys hashname Get all key
- hvals hashname Get all value
- hlen hashname To obtain the length of the ( Namely map The number of key value pairs inside )
list
- lpush listname value1 value2 value3 Insert left
- rpush listname value1 value2 value3 Right insert
- lrange listname start end From 0 Everything from the first to the last ( Including head and tail )
- lpop listname Pop up an element on the left
- rpop listname Pop up an element on the right
- llen listname Get the length of the list ( Element number )
- lrem listname conunt value Remove elements for example :lrem list1 2 ccc : Delete list1 The two values from the left are ccc The elements of , The returned value is the number of deleted
- lindex listname index(0,1 etc. ) Take out No n It's worth , Index starts from zero
- lset list index value Set the value of the index
- ltrim list startindex endindex Intercept list Some of the elements of , Delete other elements
- linsert list before value towards list Medium value Insert... Before element
- linsert list after value towards list Medium value Insert after element
- rpoplpush sourcelist destinationlist take sourcelist Pop up an element on the right , Insert left destinationlist, Return that element
- sort listname alpha Alphabetical order
set
- sadd set value1 value2 value3 towards set Add elements to it , Returns the number of elements successfully added
- smembers set set All elements in
- srem set value1 value2 Delete elements from the collection , Returns the number of successfully deleted
- sismember set value Judge value Whether there is set in , return 0 perhaps 1
- scard set obtain set Number of members of the set
- sdiff set1 set2 seek set1 and set2 And return
- sinter set1 set2 seek set1 and set2 Intersection of and return to
- sunion set1 set2 seek set1 and set2 Union
- srandom set from set Take random elements
- spop set Pop up the first element from the collection , Return the pop-up element
zset Ordered set ( Ranking List )
- zadd zset score value … towards zset Add elements to it , Can be added more than once , Returns the number of added elements , for example zadd zset 1 jack 2 mike 3 lily If there is only one element , Just return the score of this element
- zincrby zset score value to value Elements increase scores , for example :zincrby zset 2 lily to lily Element increases by two points
- zcard zset obtain set Number of members of the set
- zscore zset value Get the score of this element
- zrange zset beginindex endindex withscores Get all the elements of the set through fractional sorting , And show the score , With head and tail
- zcount zset minscore maxscore Get the number of members in the specified score interval
- zrangebyscore zset min max withscores Gets the element of the specified range ( With head and tail )
- zrangebyscore zset min max withscores limit 0,10 Pagination ( skip 0 strip , take 10 Data , If you inquire about page 5 , Namely 40,10)
- zrem zset value1 value2 Remove elements from collection , The return value is the number of elements removed
- zremrangebyrank minrank maxrank Remove the elements of the specified ranking interval
- zremrangebyscore minscore maxscore Remove the element of the specified score interval
- zrank zset element Returns the index of the specified element , from 0 Start
- zrevrank zset element Returns the index of the specified element , In reverse order of fractions
边栏推荐
- JVM 垃圾回收 详细学习笔记(二)
- 華為HCIP-DATACOM-Core_03day
- Expérience de port série - simple réception et réception de données
- What is the rating of Huishang futures company? Is it safe to open an account? I want to open an account, OK?
- Confitest of fixture py
- 答案在哪里?action config/Interceptor/class/servlet
- Leetcode question brushing record (array) combination sum, combination sum II
- Systick滴答定时器
- Several stages of PMP preparation study
- 2020 year end summary
猜你喜欢
STM32串口寄存器库函数配置方法
嵌套(多级)childrn路由,query参数,命名路由,replace属性,路由的props配置,路由的params参数
MySQL common statements
Skill review of test engineer before interview
Common short chain design methods
Jenkins+ant+jmeter use
What is the use of PMP certificate?
STM32 serial port register library function configuration method
C language pointer (exercises)
信息安全实验四:Ip包监视程序实现
随机推荐
C语言指针(中篇)
Entity of cesium data visualization (Part 1)
Count the number of words C language
Add new item after the outbound delivery order of SAP mm sto document is created?
Unittest simple project
What are the conditions for applying for NPDP?
Interview question: general layout and wiring principles of high-speed PCB
Troublesome problem of image resizing when using typora to edit markdown to upload CSDN
Chaosblade: introduction to chaos Engineering (I)
C语言指针(习题篇)
Regularly modify the system time of the computer
Original collection of hardware bear (updated on May 2022)
Interpretation of MySQL optimization principle
Simulation volume leetcode [general] 1557 The minimum number of points that can reach all points
(3/8) method parameters of improper use of enumeration (2)
STM32的时钟系统
Huawei HCIP - datacom - Core 03 jours
数据在内存中的存储
Reading notes of pyramid principle
Pytest installation (command line installation)