设为首页 加入收藏

TOP

【Redis2】Redis数据库的学习与实践―redis的数据类型(二)
2015-07-24 11:37:32 来源: 作者: 【 】 浏览:10
Tags:Redis2 Redis 数据库 学习 实践 redis 数据 类型
:6379> hmset myhash field2 helloyou field3 hellome

OK

127.0.0.1:6379> hmget myhash field2 field3

1) "helloyou"

2) "hellome"

hincrby

指定的hashfield加上给定值。

127.0.0.1:6379> hset myhash field4 30

(integer) 1

127.0.0.1:6379> hincrby myhash field4 10

(integer) 40

127.0.0.1:6379> hget myhash field4

"40"

127.0.0.1:6379>

hexists

测试指定field是否存在。

127.0.0.1:6379> hexists myhash field1

(integer) 1

hlen

返回指定hash的field数量。

127.0.0.1:6379> hlen myhash

(integer) 4

hdel

删除指定hash的field。

127.0.0.1:6379> hdel myhash field4

(integer) 1

127.0.0.1:6379>

hkeys

返回hash的所有field。

127.0.0.1:6379> hkeys myhash

1) "field1"

2) "field2"

3) "field3"

hvals

返回hash的所有value。

127.0.0.1:6379> hvals myhash

1) "hello"

2) "helloyou"

3) "hellome"

(10)hgetall

获取某个hash中全部的field和value。

127.0.0.1:6379> hgetall myhash

1) "field1"

2) "hello"

3) "field2"

4) "helloyou"

5) "field3"

6) "hellome"

3:List类型及操作:

List是一个链表结构,主要功能是push,pop,获取一个范围的所有值等等,操作中Key理解为链表的名字。

Redis的list类型其实就是一个每个子元素都是string类型的双向链表。我们可以通过puth,pop操作从链表的头部或者尾部添加删除元素,这样list既可以作为栈,又可以作为队列。

对Redis的数据类型的介绍就到这里,还有两种数据类型,Set类型和Zset类型就不详细介绍了。
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MongoDB应用实践思考 下一篇内连接和外连接

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Shell 中各种括号的 (2025-12-24 19:50:39)
·Shell 变量 - 菜鸟教 (2025-12-24 19:50:37)
·Linux source 命令 - (2025-12-24 19:50:34)
·switch520最新的地址 (2025-12-24 19:19:41)
·微信聊天功能使用了 (2025-12-24 19:19:39)