redis 127.0.0.1:6379> set name "zhangshan" //Assign key name zhangshan OK redis 127.0.0.1:6379> get name "zhangshan" getrange String interception redis 127.0.0.1:6379> getrange name 0 3 //Intercept the substring of 0-3 "zhan" getset sets the new value and returns the old value redis 127.0.0.1:6379> getset name "wangwu" //Assign the specified key and return the previous value "zhangshan" redis 127.0.0.1:6379> get name //Check the value of name and it becomes wamgwu "wangwu" setex sets the key value and sets the expiration time redis 127.0.0.1:6379> setex name 30 "zbb" //Set the value of the key whose key is name to zbb, and set the expiration time to 3 seconds OK redis 127.0.0.1:6379> get name "zbb" redis 127.0.0.1:6379> ttl name //Expire after 13 seconds left (integer) 13 strlen gets the length of a string value. redis 127.0.0.1:6379> set name "zbbbbb" OK redis 127.0.0.1:6379> strlen name //Get the length of the string value stored by key as name (integer) 6 mset sets multiple key-value pairs at the same time redis 127.0.0.1:6379> mset key1 "c++" key2 "c#" key3 "java" key4 "node.js" OK redis 127.0.0.1:6379> get key1 "c++" redis 127.0.0.1:6379> get key2 "c#" redis 127.0.0.1:6379> get key3 "java" redis 127.0.0.1:6379> get key4 "node.js" append appends a string redis 127.0.0.1:6379> set zbb_key "ku bi cheng xu yuan !" OK redis 127.0.0.1:6379> append zbb_key "yes we all" //Append "yes we all" to the string stored in key zbb_key (integer) 29 redis 127.0.0.1:6379> get zbb_key //Check the result again, it has been added "ku bi cheng xu yuan ! yes we all" redis 127.0.0.1:6379>
String type common operations for redis data type operations
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326756511&siteId=291194637
Recommended
Ranking