1
This commit is contained in:
parent
c700b16108
commit
1f208b8fbd
@ -18,11 +18,14 @@ context = {
|
||||
'dbname_prefix': ''
|
||||
}
|
||||
|
||||
def scanKeys(r, key_prefix, keys):
|
||||
def scanKeys(r, key_prefix, matched_keys):
|
||||
scan_key = key_prefix + '*'
|
||||
keys = []
|
||||
cursor, keys = r.scan(0, scan_key, 1000)
|
||||
scan_count = 0
|
||||
while cursor != 0 or len(keys) > 0:
|
||||
for key in keys:
|
||||
matched_keys[key] = key
|
||||
#end
|
||||
keys = []
|
||||
if cursor != 0:
|
||||
@ -32,7 +35,12 @@ def scanKeys(r, key_prefix, keys):
|
||||
break
|
||||
#end while cursor
|
||||
|
||||
def saveKeys(r, keys, curr_file):
|
||||
for key in keys:
|
||||
data = r.get(key)
|
||||
|
||||
def exportRedis(context, redis_conf, redis_rule_conf):
|
||||
curr_file = open(context['out_dir', 'w'])
|
||||
for conf in redis_conf:
|
||||
r = redis.Redis(host = conf['host'],
|
||||
port = conf['port'],
|
||||
@ -40,9 +48,9 @@ def exportRedis(context, redis_conf, redis_rule_conf):
|
||||
charset = 'utf8'
|
||||
)
|
||||
for rule in redis_rule_conf:
|
||||
keys = {}
|
||||
scanKeys(r, rule['key_prefix'], keys)
|
||||
#end for rule
|
||||
matched_keys = {}
|
||||
scanKeys(r, rule['key_prefix'], matched_keys)
|
||||
saveKeys(r, curr_file, matched_keys)
|
||||
#end for conf
|
||||
|
||||
def main():
|
||||
|
Loading…
x
Reference in New Issue
Block a user