def test_set_to_cache(rdc: RedisCache) -> None: key = "teste:1" value = 10 rdc.set_to_cache(key, value) cache = pickle.loads(rdc.get(key)) assert cache assert cache == 10 rdc.delete(key)
def test_get_from_cache(rdc: RedisCache) -> None: key = "teste:2" value = 20 rdc.setex(key, timedelta(seconds=3600), value=pickle.dumps(value)) cache = rdc.get_from_cache(key) assert cache assert cache == value rdc.delete(key)
def test_invalidate_cache(rdc: RedisCache) -> None: key = "teste:4" value = 20 rdc.setex(key, timedelta(seconds=3600), value=pickle.dumps(value)) cache = rdc.get(key) assert cache rdc.invalidate_cache(key) cache = rdc.get(key) assert cache is None rdc.delete(key)
def test_get_from_cache_none(rdc: RedisCache) -> None: key = "teste:3" cache = rdc.get_from_cache(key) assert cache is None rdc.delete(key)