标签:des cto 阻塞 color red store http sel 分析
Redis底层提供了5种数据结构:字符串、哈希、列表、集合、有序集合
下图非常形象的表示了数据结构:
SET key value [EX seconds] [PX milliseconds] [NX|XX]
MSET key value [key value...]
SETNX key value
GET key
MGET key [key...]
DEL key [key...]
EXPIRE key seconds
INCR key
DECR key
INCRBY key increment
INCRBY key decrement
SET sentinel:status 1
GET sentinel:status
SET user:1001 {"userId":1001, "userName":"张三", "age":28}
GET user:1001
MSET user:1001:name 张三 user:1001:age 28
MGET user:1001:name user:1001:age
返回1表示获取锁成功,返回0表示获取锁失败
SET lock:product:100001 1 EX 30 NX
处理成功后释放锁
DEL lock:product:100001
INCR article:readcount:18021 // 文章id为18021阅读数量+1
GET article:readcount:18021 // 查询文章id为18021阅读数量
DECR product:count:100001 // 产品id为100001库存-1
GET product:count:100001 // 查询产品id为100001库存
SET sessionId {"userId":1001,"name":"张三","auth":""}
INCRBY order:ids 1000 // 给订单服务生成1000个主键id
HSET key field value
HSETNX key field value
HMSET key field value [field value ...]
HGET key field
HMGET key field [field ...]
HDEL key field [field ...]
HLEN key
HGETALL key
DEL key
HINCRBY key field increment
hmset userinfo id:1001:name 张三 id:1001:age 28
hmget userinfo id:1001:name id:1001:age
hmset user:1001 id 1001 name 张三 age 28
expire user:1001 30
hgetall user:1001
用户id为key,商品id为field,商品数量为value
hset cart:user:1001 10088 1
hset cart:user:1001 10072 1
hset cart:user:1001 10192 1
hincrby cart:user:1001 10088 1
hlen cart:user:1001
hdel cart:user:1001 10072
hgetall cart:user:1001
同类数据归类整合储存,方便数据管理,相比string操作消耗内存与cpu更小,相比string储存更节省空间
过期功能只能设置在key上,无法对field单独设置key,一个key不能存太多的field
LPUSH list value [value ...]
RPUSH list value [value ...]
LPOP list
RPOP list
LRANGE list start stop
BLPOP list [timeout]
BRPOP list [timeout]
利用list的LPUSH + BRPOP实现一个消息队列,故而可以实现一个简单的点对点消息队列
利用RPUSH + LRANGE组合实现点赞用户列表功能
利用LPUSH + LRANGE组合实现消息推送功能
SADD key [member] [member...]
SREM key [member] [member...]
SMEMBERS key
SCARD key
SISMEMBER key member
SRANDMEMBER key [count]
SPOP key [count]
郑州知名妇科医院[排名]例假过后第四天同房会怀孕吗http://news.39.net/zztjyy/210511/8938729.html
例假过后几天又出血[河南郑州妇科医院排行榜]http://news.39.net/zztjyy/210511/8938750.html
【郑州妇科哪家好】怀孕了见红了怎么回事http://news.39.net/zztjyy/210512/8940052.html
SINTER key [key...]
SINTERSTORE destination key1 [key2]
SUNION key1 [key2]
SUNIONSTORE destination key1 [key2]
SDIFF key1 [key2]
SDIFFSTORE destination key1 [key2]
SADD draw:prizes:1001 10293
SMEMBERS draw:prizes:1001
SPOP draw:prizes:1001
SPOP draw:prizes:1001 N
SADD collect:article:1001 29102
郑州妇科医院哪家好:http://yyk.39.net/zz3/zonghe/1d426.html
郑州妇科医院排名:http://jbk.39.net/yiyuanfengcai/yyjs_sysdfkyy/
SREM collect:article:1001 29102
SISMEMBER collect:article:1001 29102
SMEMBERS collect:article:1001
SCARD collect:article:1001
[郑州检查妇科]女生私密出长了个疙瘩咋回事http://news.39.net/zztjyy/210512/8940458.html
{郑州妇科哪一家医院好}女生外阴瘙痒怎么办http://news.39.net/zztjyy/210512/8940479.html
女生下边痒是怎么回事{郑州妇科检查哪家好}http://news.39.net/zztjyy/210512/8940502.html
ZADD key score1 member1 [score2 member2]
ZREM key member [member...]
ZSCORE key member
ZINCRBY key increment member
ZCARD key
ZRANGE key start stop [WITHSCORES]
ZREVRANGE key start stop [WITHSCORES]
ZUNIONSTORE destkey numkeys key [key ...]
ZINTERSTORE destkey numkeys key [key ...]
ZINCRBY hotnews:20210426 1 10001
ZREVRANGE hotnews:20210426 0 10 WITHSCORES
ZUNIONSTORE hotnews:20210426-20210502 hotnews:20210426 hotnews:20210427 ... hotnews:20210502
ZREVRANGE hotnews:20210426-20210502 0 10 WITHSCORES
标签:des cto 阻塞 color red store http sel 分析
原文地址:https://www.cnblogs.com/sunjuhg/p/14759712.html