当前位置:网站首页>Redis common commands

Redis common commands

2022-06-22 10:55:00 dhjywe

1. Basic operation of string

#  Writing data 
set  key values
set  name Tom
#  Set multiple keys 
mset x 1 y 2 z 3
mget x y z
#  Do not modify duplicate keys 
setnx name top
 In this way, no one else can modify it 
#  Set the validity period of the key 
setex key time value( Grammar format )
ep:setex name 10 wei( Set up 10s Time validity )
#  Get the length of the key value string 
strlen name
#  Set new key to get old value 
> GETSET db mongo
> nil        #  No old value returned nil
> get db
> mongo

> GETSET db redis
> mongo      #  Return old value 
> get db
> redis

2. Numeric type operation

set count 90
incr count          ##  Self increasing 1
decr count          ##  Self reduction 1
incrby count 10     ##  Self increasing 10
原网站

版权声明
本文为[dhjywe]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221041345414.html