Skip to content

Documentation: Redis caching backend #1356

@daberlin

Description

@daberlin

Hi.
I'm using Redis as a caching backend for Zeep in a project of mine.
Maybe it would be helpful for others to add the below (minimal) sample to the docs:

class ZeepRedisCache(zeep.cache.Base):
    redis = None
    expiry = None

    def __init__(self, redis_host: str, redis_db: int, expiry: int = 86400) -> None:
        self.redis = redis.Redis(host=redis_host, db=redis_db)
        self.expiry = expiry

    def add(self, url: str, content: bytes) -> None:
        self.redis.setex(url, self.expiry, content)

    def get(self, url: str) -> bytes | None:
        return self.redis.get(url)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions