当前位置:网站首页>Redis basic commands and types
Redis basic commands and types
2022-06-25 01:20:00 【Lutrra】
Basic commands
keys *
type name
set name lutrra
get name
mv name 1
ttl
exist name
expire name 10
flashdb
type
String
append name "hello" # Append string
srtlen name # Check the length
# Addition and subtraction
set views 0
incr views # Add
decr view # reduce
incrby views 10# Add 10
decr views 10 # reduce 10
# String range
set name "lutrra"
getrange name 0 3 #0-3
getrange name 0 -1 # Intercept all
# Replace
setrange name 1 xx # hold key by name Replace 1 Starting string
#
setex #( There is ) Set it up
setnx #( non-existent ) Set up
# Set multiple values
mset k1 v1 k2 v2 k3 v3
mget k1 k2 k3
msetnx k1 v1 k4 v4 # Or make it together , Or fail together
# object
set user:1 {
name:zhang,age:3} # Set an object The value is json preservation
mset user:1:name zhangsan user:1:age 2
mget user:1:name user:1:age
#key The design of the
#user:{id}:{filed}
# Combination order
getset # First get Again set
getset db redsi
list
lpush list one # Place one or more values from the left
lrange list 0 -1
lrange list 0 1
rpush list right # Put... From the right
lpop list # Remove the first... In the current list
rpop list # Remove the last element of the list
lindex list 1 # Get the first value by subscript
rindex list 1
Llenlist # Return length
lrem list 1 one # Remove the specified value Remove one of them one
trim # trim
ltrim list 1 2
rpoplpush list otherlist# Move to new list
exist list
lset # Replace the value of the list subscript with another value
linsert list before "hh" # Insert forward
linest list after "jj" # Insert after
set
sadd myset hello # Additive elements
smembers myset # Check all values
smember myset hello # Judge whether it is set in
scard myset # obtain set The number of elements in the collection
srem myset hello # remove
set# Disorder does not repeat
srandmember myset # Random sampling
srandmember myset 2# Random sampling 2 individual
# Delete specified key
spop myset # Random delete
smove myset myset2 "kuangshen"# Move the specified element
# Difference set
sdiff key1 key2
# intersection
sinter key1 key2
# Combine
sunion key1 key2
Hash
hset myhash filed1 lutrra # Storage
hget myhash filed1 # Value
mset muhash filed1 hello filed2 world #hmset 4.0 obsolete
hgetall myhash # Query all
hdel myhsah filed # Delete specified key
hlen myhash # Get the number of hash tables
hexist myhash filed1# Determine whether the specified field of the hash exists
hincr hdecr
hsetnx
hset user:1
zset
# stay set Add sorting on the basis of
zadd myzset 1 one
zadd myzset 2 two
zrange myset 0 -1
# Sort
zadd salary 2500 zs
zadd salary 5000 xh
zadd salary 100 xx
#min max
zrangebyscore salary -inf +inf
zrangescore salary -inf +inf withscores
# Remove elements
zrange salary 0 -1
zrem salary xx
# Check out the elements Get the number of ordered sets
zcard salary
# reverse
zrevrange salary 0 -1
# Get the number of members in the specified interval
zcount salary 1100 6000
geospatial
# Determination of geographical location
# longitude , latitude
geoadd china:city 116.40 39.90 beijing
geoadd china:city 121.47 31.23 shanghai
geoadd china:city 106.50 29.53 chongqing
# Get the longitude and latitude of the specified city
geops china:city beijing
# The distance between the two
geodist china:city beijing shanghai km
# The man near the Centered on a given latitude and longitude , A radius search withcoord count
georadius china:city 110 30 1000 km
georadiusbymember china:city beijing 100km
# return hash length Convert two-dimensional latitude and longitude to one-dimensional string
geohash china:city beijing shanghai
# see
zrange china:city 0 -1
zrem china:city beijing
hyperloglog
# Base Statistics
pfadd mykey a b c d
PFCOUNT mykey
PFadd mykey2 i j k
PFMERGE mykey3 mykey mykey2
bitmaps
# Bit storage Count the number of people 01 Statistics
# Monday to Sunday 0 1 2 3 4 5 6
setbit sign 0 0
setbit sign 1 1
setbit sign 2 0
setbit sign 3 0
setbit sign 4 0
setbit sign 5 0
setbit sign 6 0
# see
getbit sign 6
# Statistics
bitcount sign
边栏推荐
- Reading notes at night -- deep into virtual function
- Contentresolver, get the SMS content
- pbcms添加循环数字标签
- Using bindservice method to pause music playing
- Mysql database Chapter 1 Summary
- 4 ans d'expérience de travail, 5 modes de communication Multi - thread ne peuvent pas être décrits, vous osez croire?
- Introduction to bi-sql wildcards
- Cloud development technology summit · public welfare programming challenge [hot registration]!
- 2种常见的设备稼动率OEE监测方法
- 天书夜读笔记——反汇编引擎xde32
猜你喜欢
AutoCAD - two extension modes
Abnova丨5-甲基胞嘧啶多克隆抗体中英文说明
扎克伯格上手演示四款VR头显原型机,Meta透露元宇宙「家底」
4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
Boutique enterprise class powerbi application pipeline deployment
新一代可级联的以太网远程I/O数据采集模块
15.线程同步的几种方法
重磅:国产IDE发布,由阿里研发,完全开源!(高性能+高定制性)
Assembly language (3) 16 bit assembly basic framework and addition and subtraction loop
天书夜读笔记——深入虚函数virtual
随机推荐
Merge sort template & understanding
Bi-sql index
Using macro code to generate handwriting automatically in word or WPS
The optimism about technology is making Dell achieve more than expected
改造一下 BeanUtils,优雅的实现 List 数据拷贝
15. several methods of thread synchronization
欢迎来到联想智能大屏的新世界
1. 封装自己的脚手架 2.创建代码模块
汇编语言(2)基础知识-debug
mysql查询时间戳转换成日期格式
JVM directive
Which securities company should I choose to open an account online? Is it safe to open an account online?
Super detailed description and derivation of convolution and deconvolution (deconvolution is also called transpose convolution and fractional step convolution)
1. package your own scaffold 2 Create code module
Why does Dell always refuse to push the ultra-thin commercial notebook to the extreme?
Go language operators (under Lesson 8)
新手看过来,带你一次性了解“软考”
卷积与转置卷积
WinXP内核驱动调试
15.线程同步的几种方法