基于redis-py构建的Pythonic Redis抽象
项目描述
- 版本:
- 0.0.1
简介
Braindump
>>> from redish.client import Client
>>> x = Client()
# Key/Value
>>> x["foo"] = {"name": "George"}
>>> x["foo"]
{'name': 'George'}
>>> del(x["foo"])
>>> x["foo"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "redish/client.py", line 52, in __getitem__
raise KeyError(key)
KeyError: 'foo'
# Sets
>>> s = x.Set("myset")
>>> map(s.add, ["opera", "firefox", "ie", "safari"])
[True, True, True, True]
>>> "opera" in s
True
>>> s.remove("safari")
>>> "safari" in s
False
>>> list(s)
['opera', 'ie', 'firefox']
>>> s2 = x.Set("myset2")
>>> map(s2.add, ["opera", "firefox", "mosaic"])
[True, True, True]
>>> s.difference(s2)
set(['opera', 'firefox', 'mosaic'])
# Sorted Set
>>> z = x.SortedSet("myzset")
>>> z.add("foo", 0.9)
True
>>> z.add("bar", 0.1)
True
>>> z.add("baz", 0.3)
True
>>> z[0:3]
['bar', 'baz', 'foo']
安装
您可以通过Python包索引(PyPI)或从源代码安装redish。
使用pip安装:
$ pip install redish
使用easy_install安装:
$ easy_install redish
如果您已下载源代码压缩包,可以按照以下步骤安装:
$ python setup.py build # python setup.py install # as root
示例
项目详情
关闭
redish-0.0.1.tar.gz的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | d81db76cba4ab5975fba3664d8f5cf5f016e0fb843ae6665a06123e7e411cd48 |
|
| MD5 | 86cb2770655200ee345c8bac3f5d7fe0 |
|
| BLAKE2b-256 | bc43c7760e672ec9fbe1593aa0bddb00e850fb949432fa71903427bfa2549994 |