redis hash结构及命令详解
来源:互联网 发布:苹果电脑安装软件 编辑:程序博客网 时间:2024/05/01 05:16
hash特别适用于存储对象:
例子:设置一个人的基本信息
redis 127.0.0.1:6379> HMSET user:userid:5 name “zhangsan” age 20 gender “male”
redis 127.0.0.1:6379> HGETALL user:userid:5
1) "name"
2) "zhangsan"
3) "age"
4) "20"
5) "gender"
6) "male"
--------------------------------------------------------------
也可以一个一个设置值:
redis 127.0.0.1:6379> HMSET user:userid:5 name “zhangsan”
redis 127.0.0.1:6379> HMSET user:userid:5 age 20
redis 127.0.0.1:6379> HMSET user:userid:5gender “male”
redis 127.0.0.1:6379> HGETALL user:userid:5
1) "name"
2) "zhangsan"
3) "age"
4) "20"
5) "gender"
6) "male"
hset key field value
作用: 把key中 filed域的值设为value
注:如果没有field域,直接添加,如果有,则覆盖原field域的值
hmset key field1 value1 [field2 value2 field3 value3......fieldn valuen]
作用: 设置field1->N 个域, 对应的值是value1->N
(对应PHP理解为 $key = array(file1=>value1,field2=>value2 ....fieldN=>valueN))
hget key field
作用: 返回key中field域的值
hmget key field1 field2 fieldN
作用: 返回key中field1 field2 fieldN域的值
hgetall key
作用:返回key中,所有域与其值
hdel key field
作用: 删除key中 field域
hlen key
作用: 返回key中元素的数量
hexists key field
作用: 判断key中有没有field域
hinrby key field value
作用: 是把key中的field域的值增长整型值value
hinrby float key fieldvalue
作用: 是把key中的field域的值增长浮点值value
hkeys key
作用: 返回key中所有的field
kvals key
作用: 返回key中所有的value
- redis hash结构及命令详解
- hash结构及命令详解
- redis set集合结构及命令详解
- redis中的hash结构的相关命令
- Redis Hash命令
- redis hash命令操作
- redis命令(hash)
- redis数据结构hash命令
- Redis hash 命令
- Redis Hash命令
- redis之hash命令
- redis hash和string类型命令操作详解
- redis命令详解与使用场景举例——Hash
- redis的String结构和命令详解
- string结构及命令详解
- list结构及命令详解
- set结构及命令详解
- Hash结构详解
- 51nod--1069 Nim 游戏(博弈论)
- Bootstrap 响应式布局模板
- 使用mven编译apache-shiro出错
- android listview改变字体的大小、颜色
- Codeforces Round #343 (Div. 2) B. Far Relative’s Problem(O(1)的线段标记)
- redis hash结构及命令详解
- Spring auto wire(自动装配) 的 五种方式
- Hive日志分析案例二
- Android AsynTask
- 234. Palindrome Linked List
- Unexpected text found in layout file
- redis中的事务
- iOS开发中代码块的使用
- poj 3667 hotel