分类: 系统运维
2012-09-05 09:31:37
redis 127.0.0.1:6379> hset myhash field1
Hello (integer) 1 redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hsetnx myhash field "Hello" (integer) 1 redis 127.0.0.1:6379> hsetnx myhash field "Hello" (integer) 0 redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hmset myhash field1 Hello field2 World OK redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hget myhash field1 "Hello" redis 127.0.0.1:6379> hget myhash field2 "World" redis 127.0.0.1:6379> hget myhash field3 (nil) redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hmget myhash field1 field2 field3 1) "Hello" 2) "World" 3) (nil) redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hset myhash field3 20 (integer) 1 redis 127.0.0.1:6379> hget myhash field3 "20" redis 127.0.0.1:6379> hincrby myhash field3 -8 (integer) 12 redis 127.0.0.1:6379> hget myhash field3 "12" redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hexists myhash field1 (integer) 1 redis 127.0.0.1:6379> hexists myhash field9 (integer) 0 redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hlen myhash (integer) 4 redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hlen myhash (integer) 4 redis 127.0.0.1:6379> hdel myhash field1 (integer) 1 redis 127.0.0.1:6379> hlen myhash (integer) 3 redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hkeys myhash 1) "field2" 2) "field" 3) "field3" redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hvals myhash 1) "World" 2) "Hello" 3) "12" redis 127.0.0.1:6379> |
redis
127.0.0.1:6379> hgetall myhash 1) "field2" 2) "World" 3) "field" 4) "Hello" 5) "field3" 6) "12" redis 127.0.0.1:6379> |
可见,一下子将myhash 中所有的field 及对应的value
都取出来了。
好了,游龙剑的技能也都传授给大家了,不知道大家能掌握多少,Redis是一个很不错的数据库,希望大家能认真看下,有什么不明白的知识点,及时反馈回帖!
原文地址: