string 类型应用场景 解决方案 127.0.0.1:6379> hset user name zhangsan (integer) 1 127.0.0.1:6379> hset user age 23 (integer) 1 127.0.0.1:6379> hset user weight 70 (integer) 1 127.0.0.1:6379> hgetall user
- “name”
- “zhangsan”
- “age”
- “23”
- “weight”
- “70”
127.0.0.1:6379> hget user name “zhangsan” 127.0.0.1:6379> hdel user weight (error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. 127.0.0.1:6379> config set stop-writes-on-bgsave-error no OK 127.0.0.1:6379> hdel user weight (integer) 1 127.0.0.1:6379> hgetall user - “name”
- “zhangsan”
- “age”
- “23”
127.0.0.1:6379> hmget user name age - “zhangsan”
- “23”
127.0.0.1:6379> hmset user name zhangsanfeng weight 75 OK 127.0.0.1:6379> hgetall user - “name”
- “zhangsanfeng”
- “age”
- “23”
- “weight”
- “75”
127.0.0.1:6379> hexists user weight (integer) 1 127.0.0.1:6379> hexists user height (integer) 0 127.0.0.1:6379> hset user2 name zs (integer) 1 127.0.0.1:6379> hkeys user2 - “name”
127.0.0.1:6379> hvals user2 - “zs”
127.0.0.1:6379> hincrby user age 1 (integer) 24 127.0.0.1:6379> hmget user age - “24”
127.0.0.1:6379> hget user name “zhangsanfeng” 127.0.0.1:6379> hmset 003 g01:nums 100 g01:info {} OK 127.0.0.1:6379> hgetall 003 - “g01:nums”
- “100”
- “g01:info”
- “{}”
127.0.0.1:6379> hmset 004 g01:nums 5 g01:info {} OK 127.0.0.1:6379> hgetall 004 - “g01:nums”
- “5”
- “g01:info”
- “{}”
127.0.0.1:6379> hset 003 g01:nums 300 (integer) 0 127.0.0.1:6379> hgetall 003 - “g01:nums”
- “300”
- “g01:info”
- “{}”
127.0.0.1:6379> hsetnx 003 g01:nums 500 (integer) 0 127.0.0.1:6379> hgetall 003 - “g01:nums”
- “300”
- “g01:info”
- “{}”
127.0.0.1:6379> hsetnx 003 g05:nums 1 (integer) 1 127.0.0.1:6379> hgetall 003 - “g01:nums”
- “300”
- “g01:info”
- “{}”
- “g05:nums”
- “1”
127.0.0.1:6379> hkeys 003 - “g01:nums”
- “g01:info”
- “g05:nums”
127.0.0.1:6379> hvals 003 - “300”
- “{}”
- “1”
|