Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis-load is not adding the data to redis due to invalid ttl value #62

Closed
shridharcs opened this issue Aug 12, 2019 · 5 comments
Closed

Comments

@shridharcs
Copy link

shridharcs commented Aug 12, 2019

Hello,

I am new to use this utility.
I am seeing an issue in which dump works well but load is not working or in other words redis set is not working.

My dump file looks as follows.
./redisdl.py --pretty > dump.json
{
"myKey": {
"expireat": 1565594482.6172411,
"ttl": -0.001,
"type": "string",
"value": "10"
},
"myhash": {
"expireat": 1565594482.61765,
"ttl": -0.001,
"type": "hash",
"value": {
"value": "key"
}
}
}

So while adding since ttl is -1 it is not able to set the data in redis.
./redisdl.py -l dump.json

This is due to this.
https://github.com/p/redis-dump-load/blob/master/redisdl.py#L490
r.pexpire_or_expire_pipeline(p, key, ttl)

If i comment the line then the data insertion is OK.
Basically what the function pexpire_or_expire_pipeline does is return p.pexpire(key, int(ttl * 1000)), so ttl is set to -1 and hence the key is expired.

So could someone tell me how to get around this issue?
Or do i need to pass something else during dump, i didnt see any in help text/code.

Same issue is seen even with --use-expireat as well.

Is this known issue or am i missing something?

@shridharcs
Copy link
Author

shridharcs commented Aug 12, 2019

hello,

Issue is due to this.
Simple working example,

import redis
r = redis.StrictRedis(host="localhost", port=6379, db=0)
p = r.pipeline(transaction=False)
p.set("Shridhar", "CS")
Pipeline<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>
p.execute()
[True]
r.get("Shridhar")
'CS'

Non Working,

import redis
r = redis.StrictRedis(host="localhost", port=6379, db=0)
p = r.pipeline(transaction=False)
p.set("Shridhar", "CS")
Pipeline<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>
p.pexpire("Shridhar", int(-0.001 * 1000))
Pipeline<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>
p.execute()
[True, 1L]
r.get("Shridhar")

This is evident from this as well.
127.0.0.1:6379> set Shridhar CS
OK
127.0.0.1:6379> get Shridhar
"CS"
127.0.0.1:6379> PEXPIRE Shridhar -1
(integer) 1
127.0.0.1:6379> get Shridhar
(nil)
127.0.0.1:6379>

So the issue is with pexpire.
Can someone tell me whether we need to update this code?

@shridharcs
Copy link
Author

Could some expert comment on this?

@p
Copy link
Owner

p commented Sep 17, 2019

It sounds like this is the same issue as #60.

hnimminh added a commit to hnimminh/redis-dump-load that referenced this issue Mar 4, 2021
@hnimminh
Copy link
Contributor

hnimminh commented Mar 4, 2021

just add an pull request to fix this issue #64.
I make some test, that fix work well for me. @shridharcs can confirm if this fix work for you.

@shridharcs
Copy link
Author

@hnimminh this works.

p added a commit that referenced this issue Apr 15, 2021
#62 accept ttl of -1 from redis-py 3.x
@p p closed this as completed Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants