Warn if TTL of redis key is -1

(imported from commit f44ccef6dee190f531537fc8f3af9354c737a17f)
This commit is contained in:
Leo Franchi
2013-06-05 16:44:22 -04:00
parent b815d7ea83
commit 21b1090f39

View File

@@ -30,12 +30,16 @@ class Command(BaseCommand):
user = None
max_calls = max_api_calls(user=user)
age = client.ttl(key)
if age == '-1':
logging.error("Found key with age of -1, will never expire: %s" % (key,))
count = count_func()
if count > max_calls:
logging.error("Redis health check found key with more elements \
than max_api_calls! (trying to trim) %s %s" % (key, count))
client.expire(key, max_api_window(user=user))
if self.trim:
client.expire(key, max_api_window(user=user))
trim_func(key, max_calls)
def handle(self, *args, **options):