1
This commit is contained in:
parent
851129ab1f
commit
a241416c47
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ target
|
||||
config/
|
||||
__pycache__/
|
||||
res
|
||||
out/
|
@ -39,7 +39,25 @@ def scanKeys(r, key_prefix, matched_keys):
|
||||
def saveKeys(r, keys, curr_file):
|
||||
for key in keys:
|
||||
data = r.get(key)
|
||||
curr_file.write(json.dumps({'key': key, 'data':data}) + '\n')
|
||||
expire = r.ttl(key)
|
||||
curr_file.write(json.dumps(
|
||||
{
|
||||
'cmd': 'set',
|
||||
'key': key,
|
||||
'data':data
|
||||
}
|
||||
) + '\n')
|
||||
curr_file.write(json.dumps(
|
||||
{
|
||||
'cmd': 'expire',
|
||||
'key': key,
|
||||
'time': expire
|
||||
}
|
||||
) + '\n')
|
||||
if expire < 0:
|
||||
print('[ERROR] ' + key + ' ttl < 0')
|
||||
if expire > 3600 * 24:
|
||||
print('[ERROR] ' + key + ' ttl > 3600 * 24')
|
||||
|
||||
def exportRedis(context, redis_conf, redis_rule_conf):
|
||||
curr_file = open(context['out_dir'] + context['channel'] + '.redis', 'w')
|
||||
@ -49,7 +67,6 @@ def exportRedis(context, redis_conf, redis_rule_conf):
|
||||
password = conf['passwd'],
|
||||
decode_responses = True
|
||||
)
|
||||
print(r)
|
||||
for rule in redis_rule_conf:
|
||||
matched_keys = {}
|
||||
scanKeys(r, rule['key_prefix'], matched_keys)
|
||||
|
Loading…
x
Reference in New Issue
Block a user