BLOG
Enjoy when you can, and endure when you must.
OCT 17, 2013/数据库
学习笔记:Redis入门之数据类型 —— HASHES

HASH 类似于 Python 中的字典,其基本使用也非常简单:

HMSET 是 HSET 的升级版,支持一次传入多个键/值对

True
>>> conn.hmget('hash-key', ['k2', 'k3'])
['v2', 'v3']
3
>>> conn.hdel('hash-key', 'k1', 'k3')
True
>>> conn.hmset('hash-key2', {'short':'hello', 'long':1000*'1'})
True
>>> conn.hkeys('hash-key2')
['long', 'short']

HEXISTS 类似 Python 字典的 has_key() 或 in 方法:

False

HINCRBY 其实就是针对 STRING 的 INCR 方法:

1L
>>> conn.hexists('hash-key2', 'num')
True
COMMENTS
LEAVE COMMNT