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")

# Access cache metadata via .entries
result = await cache.get_user("123").entries
print(result.before)  # CacheEntry | None (None on miss)
print(result.after)   # CacheEntry (always present)

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.2.0.tar.gz (80.5 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.2.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: t87s-0.2.0.tar.gz
  • Upload date:
  • Size: 80.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 02a2b77864d3890ef173dac1f893a9349ec88e91a068c6a7f700e0ef3efcd79e
MD5 c867f0300de3cb797471142aa0ac10a9
BLAKE2b-256 78d8a7d06988edb90ce9525dba0811a1a13e03ae94d1e3611b1000c2b60284ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: t87s-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3e592517a4661b516735bf6b4925cd0f80f3274d20e7caae148667ec2b993d0
MD5 3f9e6fd1ad998b1dfe20a30540143ba4
BLAKE2b-256 5b4a09fd57e30cf53db21aa8663973da6400c85a8382db22f4ab7d5314f4bb5e

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