Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
796d05f8
R
redis
项目概览
hanoi2005
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
796d05f8
编写于
3月 24, 2009
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python client library updated, thanks to Ludo!
上级
5a6948fb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
0 deletion
+33
-0
client-libraries/python/redis.py
client-libraries/python/redis.py
+33
-0
未找到文件。
client-libraries/python/redis.py
浏览文件 @
796d05f8
...
...
@@ -140,6 +140,19 @@ class Redis(object):
self
.
_write
(
'GET %s
\r\n
'
%
name
)
return
self
.
_get_value
()
def
mget
(
self
,
*
args
):
"""
>>> r = Redis()
>>> r.set('a', 'pippo'), r.set('b', 15), r.set('c', '
\\
r
\\
naaa
\\
nbbb
\\
r
\\
ncccc
\\
nddd
\\
r
\\
n'), r.set('d', '
\\
r
\\
n')
('OK', 'OK', 'OK', 'OK')
>>> r.mget('a', 'b', 'c', 'd')
['pippo', '15', '
\\
r
\\
naaa
\\
nbbb
\\
r
\\
ncccc
\\
nddd
\\
r
\\
n', '
\\
r
\\
n']
>>>
"""
self
.
connect
()
self
.
_write
(
'MGET %s
\r\n
'
%
' '
.
join
(
args
))
return
self
.
_get_multi_response
()
def
incr
(
self
,
name
,
amount
=
1
):
"""
>>> r = Redis()
...
...
@@ -827,6 +840,26 @@ class Redis(object):
self
.
_write
(
'%s
\r\n
'
%
(
'FLUSHALL'
if
all_dbs
else
'FLUSHDB'
))
return
self
.
_get_simple_response
()
def
info
(
self
):
"""
>>> r = Redis()
>>> info = r.info()
>>> info and isinstance(info, dict)
True
>>> isinstance(info.get('connected_clients'), int)
True
>>>
"""
self
.
connect
()
self
.
_write
(
'INFO
\r\n
'
)
info
=
dict
()
for
l
in
self
.
_get_value
().
split
(
'
\r\n
'
):
if
not
l
:
continue
k
,
v
=
l
.
split
(
':'
,
1
)
info
[
k
]
=
int
(
v
)
if
v
.
isdigit
()
else
v
return
info
def
_get_value
(
self
,
negative_as_nil
=
False
):
data
=
self
.
_read
().
strip
()
if
data
==
'nil'
or
(
negative_as_nil
and
data
==
'-1'
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录