Here is a snapshot of my redis settings
Total Keys  Keys with Expiry    Keys without Expiry
60Lacs      20Lacs              40Lacs  
Is there any method provided by Redis:
Automatically set a TTL of 1 day on any key created by an application that doesn't specify a TTL
Remove All existing keys with no TTL
As far as question one - No, Redis does not provide a global TTL setting. The TTL has to be set on a per key basis. There are some ways you could script a solution but there is nothing built in. If you are concerned about the memory usage, look in to your configurations and modify the max-memory settings. See this answer for more information.
As far as question two - This script in Python is a basic example of how to iterate over the keys and delete anything without a TTL, you should build on it for your needs. Important information about making this performant can be found in this answer.
import redis
r = redis.StrictRedis(host='localhost', port=6379)
for key in r.scan_iter("*"):
    ttl = r.ttl(key)
    if ttl == -1:
        r.delete(key)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With