Skip to content

Commit 4e18978

Browse files
committed
Fix spacing from DEBUG OBJECT pull request.
1 parent 86fab8c commit 4e18978

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* 2.4.10 (in development)
2+
* Added the DEBUG OBJECT command.
23
* Added __del__ methods for classes that hold on to resources that need to
34
be cleaned up. This should prevent resource leakage when these objects
45
leave scope due to misuse or unhandled exceptions. Thanks David Wolever

redis/client.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,25 @@ def dict_merge(*dicts):
4545
return merged
4646

4747
def parse_debug_object(response):
48-
"Parse the results of Redis's DEBUG OBJECT command into a Python dict"
49-
res = dict([kv.split(':') for kv in ('type:' + response).split()])
50-
51-
# parse some expected int values from the string response
52-
# note: this cmd isn't spec'd so these may not appear in all redis versions
53-
possible_int_fields = ['refcount', 'serializedlength',
54-
'lru', 'lru_seconds_idle']
55-
for field in possible_int_fields:
56-
if field in res:
57-
res[field] = int(res[field])
58-
59-
return res
48+
"Parse the results of Redis's DEBUG OBJECT command into a Python dict"
49+
# The 'type' of the object is the first item in the response, but isn't
50+
# prefixed with a name
51+
response = 'type:' + response
52+
response = dict([kv.split(':') for kv in response.split()])
53+
54+
# parse some expected int values from the string response
55+
# note: this cmd isn't spec'd so these may not appear in all redis versions
56+
int_fields = ('refcount', 'serializedlength', 'lru', 'lru_seconds_idle')
57+
for field in int_fields:
58+
if field in response:
59+
response[field] = int(response[field])
60+
61+
return response
6062

6163
def parse_info(response):
6264
"Parse the result of Redis's INFO command into a Python dict"
6365
info = {}
66+
6467
def get_value(value):
6568
if ',' not in value:
6669
return value
@@ -165,7 +168,7 @@ class StrictRedis(object):
165168
'CONFIG': parse_config,
166169
'HGETALL': lambda r: r and pairs_to_dict(r) or {},
167170
'INFO': parse_info,
168-
'DEBUG' : parse_debug_object,
171+
'DEBUG': parse_debug_object,
169172
'LASTSAVE': timestamp_to_datetime,
170173
'PING': lambda r: r == 'PONG',
171174
'RANDOMKEY': lambda r: r and r or None,
@@ -325,8 +328,8 @@ def info(self):
325328
return self.execute_command('INFO')
326329

327330
def debug_object(self, key):
328-
"""Returns version specific metainformation about a give key"""
329-
return self.execute_command('DEBUG', 'OBJECT', key)
331+
"Returns version specific metainformation about a give key"
332+
return self.execute_command('DEBUG', 'OBJECT', key)
330333

331334
def lastsave(self):
332335
"""

0 commit comments

Comments
 (0)