hishel icon indicating copy to clipboard operation
hishel copied to clipboard

AsyncRedisStorage does not write to Redis

Open arseniiarsenii opened this issue 3 months ago • 1 comments

Hi, I'm using an async Httpx client with Hishel transport, that I create with such code:

transport = hishel.AsyncCacheTransport(
    transport=httpx.AsyncHTTPTransport(), 
    storage=hishel.AsyncRedisStorage(
        client=get_redis_connection(),
        ttl=300,
    ), 
    controller=hishel.Controller(
        cacheable_methods=["GET", "POST"],
        cacheable_status_codes=[200],
        allow_heuristics=False,
        clock=None,
        allow_stale=True,
        always_revalidate=False,
        force_cache=True,
        key_generator=custom_key_generator,  # Same func from docs
    )
)

I make requests using client looking at the state of my Redis instance at the same time, and can see no keys appearing. However, I can see responses are returned from cache. response.extensions["from_cache"] is True. Seems like Hishel falls back to RAM caching instead of using Redis for some reason.

arseniiarsenii avatar Mar 28 '24 09:03 arseniiarsenii