Example #1
0
    def remove_channel_exists(self, channel_id: str) -> None:
        key = RedisKeys.channel_exists()
        cache_key = '%s-%s' % (key, channel_id)
        self.redis.hdel(key, channel_id)
        self.cache.delete(cache_key)

        key = RedisKeys.channels()
        cache_key = '%s-name-%s' % (key, channel_id)
        self.cache.delete(cache_key)
        self.redis.hdel(key, channel_id)
Example #2
0
File: redis.py Project: Xlzman/dino
    def get_channel_exists(self, channel_id):
        key = RedisKeys.channel_exists()
        cache_key = '%s-%s' % (key, channel_id)
        value = self.cache.get(cache_key)
        if value is not None:
            return True

        value = self.redis.hget(key, channel_id)
        if value is None:
            return None

        self.cache.set(cache_key, True)
        return True
Example #3
0
    def test_get_channel_exists_after_expired(self):
        self.assertFalse(
            self.cache.get_channel_exists(CacheRedisTest.CHANNEL_ID))
        self.cache.set_channel_exists(CacheRedisTest.CHANNEL_ID)
        self.assertTrue(
            self.cache.get_channel_exists(CacheRedisTest.CHANNEL_ID))

        key = RedisKeys.channel_exists()
        cache_key = '%s-%s' % (key, CacheRedisTest.CHANNEL_ID)
        self.cache._del(cache_key)

        self.assertTrue(
            self.cache.get_channel_exists(CacheRedisTest.CHANNEL_ID))
Example #4
0
File: redis.py Project: Xlzman/dino
 def set_channel_exists(self, channel_id: str) -> None:
     key = RedisKeys.channel_exists()
     cache_key = '%s-%s' % (key, channel_id)
     self.redis.hset(key, channel_id, True)
     self.cache.set(cache_key, True)