redis的hash命令的學習

Last login: Tue Nov  7 14:51:18 on ttys001
➜  ~ redis-cli
127.0.0.1:6379> hset myhash field1 "foo"
(integer) 1
127.0.0.1:6379> hget myhash
(error) ERR wrong number of arguments for 'hget' command
127.0.0.1:6379> hget myhash field1
"foo"
127.0.0.1:6379> hdel myhash field2
(integer) 0
127.0.0.1:6379> hdel myhash field1
(integer) 1
127.0.0.1:6379> hset myhash field1 "foo"
(integer) 1
127.0.0.1:6379> hexists myhash field2
(integer) 0
127.0.0.1:6379> hexists myhash field1
(integer) 1
127.0.0.1:6379> hget myhash field1
"foo"
127.0.0.1:6379> hget myhash field2
(nil)
127.0.0.1:6379> hset myhash field1 "hello"
(integer) 0
127.0.0.1:6379> hset myhash field2 "world"
(integer) 1
127.0.0.1:6379> hgetall myhash
1) "field1"
2) "hello"
3) "field2"
4) "world"
127.0.0.1:6379> hset myhash field 5
(integer) 1
127.0.0.1:6379> hincrby myhash field 1
(integer) 6
127.0.0.1:6379> hincrby myhash field -1
(integer) 5
127.0.0.1:6379> hincrby myhash field -10
(integer) -5
127.0.0.1:6379> hset mykey field 10.50
(integer) 1
127.0.0.1:6379> hget mykey field
"10.50"
127.0.0.1:6379> hincrbyfloat mykey field 0.1
"10.6"
127.0.0.1:6379> hincrbyfloat mykey field -5
"5.6"
127.0.0.1:6379> hset mykey field 5.0e3
(integer) 0
127.0.0.1:6379> hincrbyfloat mykey field 2.0e2
"5200"
127.0.0.1:6379> hset myhash field1 "hello"
(integer) 0
127.0.0.1:6379> hset myhash field2 "world"
(integer) 0
127.0.0.1:6379> hkeys myhash
1) "field1"
2) "field2"
3) "field"
127.0.0.1:6379> hlen myhash
(integer) 3
127.0.0.1:6379> hmget myhash field1 field2 field
1) "hello"
2) "world"
3) "-5"
127.0.0.1:6379> hmset myhash field1 "hell" field2 "www"
OK
127.0.0.1:6379> hget myhash field1
"hell"
127.0.0.1:6379> hget myhash field2
"www"
127.0.0.1:6379> hsetnx myhash field "hello"
(integer) 0
127.0.0.1:6379> hget myhash filed
(nil)
127.0.0.1:6379> hget myhash field
"-5"
127.0.0.1:6379> hmset myhash f1 helloworld f2 99 f3 -256
OK
127.0.0.1:6379> hstrlen myhash f1
(integer) 10
127.0.0.1:6379> hstrlen myhash f3
(integer) 4
127.0.0.1:6379> hvals myhash
1) "hell"
2) "www"
3) "-5"
4) "helloworld"
5) "99"
6) "-256"
127.0.0.1:6379> hkeys myhash
1) "field1"
2) "field2"
3) "field"
4) "f1"
5) "f2"
6) "f3"
127.0.0.1:6379>
相關文章
相關標籤/搜索