Redis字符串数据类型的实践
Posted chenliangc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redis字符串数据类型的实践相关的知识,希望对你有一定的参考价值。
01:设置单个key-value对和查看单个key-value对
172.16.1.31:6379> set key1 "lili" OK 172.16.1.31:6379> get key1 "lili" ## PS:当添加key1时,若key1存在,则会修改key1之前对应的值 172.16.1.31:6379> set key1 "binbin" OK 172.16.1.31:6379> get key1 "binbin"
02:设置多个key-value对和查看多个key-value对
172.16.1.31:6379> mset key01 "chenliang" key02 "lanlan" OK 172.16.1.31:6379> mget key01 key02 1) "chenliang" 2) "lanlan" ## PS:若key01和key01存在,则会修改key01和key02之前对应的值 172.16.1.31:6379> mset key01 "chenliang666" key02 "lanlan666" OK 172.16.1.31:6379> mget key01 key02 1) "chenliang666" 2) "lanlan666"
03:向某个key中追加内容(不能同时对多个key追加内容)
172.16.1.31:6379> get key01 "chenliang666" 172.16.1.31:6379> append key01 "111111" (integer) 18 172.16.1.31:6379> get key01 "chenliang666111111"
04:判断某个key对应值的长度
172.16.1.31:6379> get key01 "chenliang666111111" 172.16.1.31:6379> strlen key01 (integer) 18
以上是关于Redis字符串数据类型的实践的主要内容,如果未能解决你的问题,请参考以下文章