This commit is contained in:
Cyberes 2023-10-05 19:35:12 -06:00
parent 8df667bc0a
commit 67173f30dd
1 changed files with 3 additions and 1 deletions

View File

@ -59,10 +59,12 @@ class RedisPriorityQueue:
print(item.decode('utf-8'))
def increment_ip_count(self, client_ip: str, redis_key):
self.redis.hincrby(redis_key, client_ip, 1)
new_count = self.redis.hincrby(redis_key, client_ip, 1)
print(client_ip, new_count)
def decrement_ip_count(self, client_ip: str, redis_key):
new_count = self.redis.hincrby(redis_key, client_ip, -1)
print(client_ip, new_count)
if new_count <= 0:
self.redis.hdel(redis_key, client_ip)