mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 10:22:43 +01:00
Fix custom redislite to account for the none errors
This commit is contained in:
parent
2cbf3fec3a
commit
4b111c035f
@ -12,16 +12,14 @@ 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)
|
return self.redis_instance.ttl(key) or 0
|
||||||
|
|
||||||
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)
|
self.redis_instance.set(key, 1, ex=expiry)
|
||||||
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)
|
self.redis_instance.set(key, int(self.redis_instance.get(key))+1, ex=oldexp)
|
||||||
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