mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
add always read redis test
This commit is contained in:
parent
f5122e0325
commit
657b7eef82
1 changed files with 27 additions and 0 deletions
|
|
@ -1958,3 +1958,30 @@ async def test_cache_default_off_acompletion():
|
|||
)
|
||||
print(f"Response4: {response4}")
|
||||
assert response3.id == response4.id
|
||||
|
||||
|
||||
@pytest.mark.asyncio()
|
||||
async def test_dual_cache_uses_redis():
|
||||
"""
|
||||
|
||||
- Store diff values in redis and in memory cache
|
||||
- call get cache
|
||||
- Assert that value from redis is used
|
||||
"""
|
||||
litellm.set_verbose = True
|
||||
from litellm.caching import DualCache, RedisCache
|
||||
|
||||
current_usage = uuid.uuid4()
|
||||
|
||||
_cache_obj = DualCache(redis_cache=RedisCache(), always_read_redis=True)
|
||||
|
||||
# set cache
|
||||
await _cache_obj.async_set_cache(key=f"current_usage: {current_usage}", value=10)
|
||||
|
||||
# modify value of in memory cache
|
||||
_cache_obj.in_memory_cache.cache_dict[f"current_usage: {current_usage}"] = 1
|
||||
|
||||
# get cache
|
||||
value = await _cache_obj.async_get_cache(key=f"current_usage: {current_usage}")
|
||||
print("value from dual cache", value)
|
||||
assert value == 10
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue