remove ttl in rdb file?

27 views
Skip to first unread message

Joel VanderKwaak

unread,
Apr 10, 2018, 4:33:12 PM4/10/18
to Redis DB
Howdy,

I have an rdb file from last year, and the interesting keys have TTLs of 60 days.

They are purged soon after loading the data into redis.

Is there any way to:
1. configure redis to ignore TTLS
2. or reset TTLs without loading the file into redis.

Thanks,

Joel

Sripathi Krishnan

unread,
Apr 11, 2018, 12:00:29 AM4/11/18
to redi...@googlegroups.com
You can use redis-rdb-tools and a small python script to solve this problem.
  1. Parse the RDB and load objects in python
  2. Store the object in redis by discarding the expiry information
Here is a short script demonstrating the idea. This depends on redis-rdb-tools and redis-py libraries available.

from rdbtools import RdbParser, RdbCallback
from redis import StrictRedis

class MyCallback(RdbCallback):
    def __init__(self):
        super(MyCallback, self).__init__(string_escape=None)
        # Redis connection where we will write the objects read from rdb
        self.red = StrictRedis()

    def set(self, key, value, expiry, info):
        # discard expiry and just write key=value into redis
        self.red.set(key, value)
    
    # depending on the data types you use, you will have to override other similar methods    

def main():
    callback = MyCallback()
    parser = RdbParser(callback)
    # path to the rdb file you want to parse
    parser.parse('dump.rdb')

if __name__ == '__main__':
    main()


--Sri

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Joel VanderKwaak

unread,
Apr 11, 2018, 12:06:47 AM4/11/18
to redi...@googlegroups.com
Thanks! I'll give it try.
Reply all
Reply to author
Forward
0 new messages