Skip to main content

Declarative cache invalidation for Python

Project description

t87s

Declarative cache invalidation for Python.

Install

pip install t87s              # Core + MemoryAdapter
pip install t87s[redis]       # + Redis support
pip install t87s[all]         # Everything

Quickstart

from t87s import QueryCache, TagSchema, Wild, AsyncMemoryAdapter, cached

class MyTags(TagSchema):
    users: Wild[TagSchema]

class MyCache(QueryCache[MyTags]):
    @cached(MyTags.users())
    async def get_user(self, id: str) -> dict:
        return await db.users.find_by_id(id)

cache = MyCache(adapter=AsyncMemoryAdapter())

# Cache miss, fetches from DB
user = await cache.get_user("123")

# Cache hit, instant
again = await cache.get_user("123")

# Invalidate when data changes
await cache.invalidate(cache.t.users("123"))

# Cache miss again, refetches
fresh = await cache.get_user("123")

Docs

Full documentation: https://docs.t87s.dev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

t87s-0.1.1.tar.gz (79.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

t87s-0.1.1-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file t87s-0.1.1.tar.gz.

File metadata

  • Download URL: t87s-0.1.1.tar.gz
  • Upload date:
  • Size: 79.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for t87s-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d0c18b29cdccb3ff7538b94e5007f2786ede7b735bac4503a53f85ec372acbfd
MD5 aa16a159a862a1b82aa71770f24bca6e
BLAKE2b-256 07dc414bef04e7593f44ab830a12c4d859dd71ceb2a600c52cf447094db54866

See more details on using hashes here.

File details

Details for the file t87s-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: t87s-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for t87s-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6d03b3421f6f4faa1aa9ee879c9ed3887883b36566f77c07a45eb3e89e6f84bb
MD5 48ec16a8b71cd523bcd810a98334483f
BLAKE2b-256 f8959c2ee0781d5bfb39ddb7854aebc9962099f1f3dc3c9fd630722d607c793f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page