mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
fixes to redis again
This commit is contained in:
parent
4b111c035f
commit
e4737444bd
@ -12,14 +12,16 @@ class LimitsRedisLite(Storage): # For Python Limits
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_expiry(self, key):
|
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):
|
def incr(self, key, expiry, elastic_expiry=False):
|
||||||
if not self.redis_instance.exists(key):
|
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:
|
else:
|
||||||
oldexp = self.get_expiry(key)
|
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
|
return
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
|
Loading…
Reference in New Issue
Block a user