From e4737444bd040b0a92a32dac57d354919a68ccf9 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 22 Apr 2017 01:46:35 -0700 Subject: [PATCH] fixes to redis again --- titanembeds/database/custom_redislite.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/titanembeds/database/custom_redislite.py b/titanembeds/database/custom_redislite.py index 0a90468..afba1e7 100644 --- a/titanembeds/database/custom_redislite.py +++ b/titanembeds/database/custom_redislite.py @@ -12,14 +12,16 @@ class LimitsRedisLite(Storage): # For Python Limits return True def get_expiry(self, key): - return self.redis_instance.ttl(key) or 0 + return (self.redis_instance.ttl(key) or 0) + time.time() def incr(self, key, expiry, elastic_expiry=False): if not self.redis_instance.exists(key): - self.redis_instance.set(key, 1, ex=expiry) + self.redis_instance.set(key, 1) + self.redis_instance.expireat(key, int(time.time() + expiry)) else: oldexp = self.get_expiry(key) - self.redis_instance.set(key, int(self.redis_instance.get(key))+1, ex=oldexp) + self.redis_instance.set(key, int(self.redis_instance.get(key))+1) + self.redis_instance.expireat(key, int(time.time() + oldexp)) return def get(self, key):