Merge "Fix the bug redis do not delete the expired keys"
This commit is contained in:
commit
ec68634d91
@ -108,7 +108,12 @@ class MatchMakerRedis(mm_common.HeartbeatMatchMakerBase):
|
||||
self.register(key, host)
|
||||
|
||||
def is_alive(self, topic, host):
|
||||
if self.redis.ttl(host) == -1:
|
||||
# After redis 2.8, if the specialized key doesn't exist,
|
||||
# TTL fuction would return -2. If key exists,
|
||||
# but doesn't have expiration associated,
|
||||
# TTL func would return -1. For more information,
|
||||
# please visit http://redis.io/commands/ttl
|
||||
if self.redis.ttl(host) == -2:
|
||||
self.expire(topic, host)
|
||||
return False
|
||||
return True
|
||||
|
@ -87,3 +87,11 @@ class RedisMatchMakerTest(test_utils.BaseTestCase):
|
||||
self.assertEqual(
|
||||
sorted(self.matcher.redis.smembers('ack_alive')),
|
||||
['ack_alive.controller1'])
|
||||
|
||||
def test_is_alive(self):
|
||||
self.assertEqual(
|
||||
self.matcher.is_alive('conductor', 'conductor.controller1'),
|
||||
True)
|
||||
self.assertEqual(
|
||||
self.matcher.is_alive('conductor', 'conductor.controller2'),
|
||||
False)
|
||||
|
Loading…
Reference in New Issue
Block a user