Skip to main content

fastcache-ai

A cache for AI workloads that needs no infrastructure. No Redis, no Docker, no connection string.

pip install fastcache-ai
from fastcache_ai import fastcache

@fastcache(ttl="15m")
def embed(prompt: str):
    return model.encode(prompt)

That is the entire setup. On first use the library finds or boots a Java engine process, reuses it across runs, and reaps it if your process dies. A JDK 21+ runtime is required; pip install "fastcache-ai[jre]" bundles one if you do not have it.

The import name is fastcache_ai, not fastcache. The bare name on PyPI belongs to an unrelated C implementation of functools.lru_cache; sharing it would make the two packages overwrite each other.

Why it exists

Caching an LLM response should be a one-line change. Instead it usually means standing up Redis, choosing a serialization format, and then discovering that a 50 MB context window on the JVM heap causes GC pauses costing more than the cache saves. FastCache stores payloads off-heap, invisible to the garbage collector, and hands you two front doors onto the same engine: this decorator, and a Spring Boot annotation for JVM services.

What you get

  • Off-heap storage sized for 20–50 MB context windows and vector matrices
  • Hot-key L1 cache — a celebrity prompt hit thousands of times per second collapses to one network round trip every few seconds
  • Stampede protection — when a hot key expires under concurrency, exactly one caller recomputes and everyone else is served the still-valid previous value
  • A management console on http://127.0.0.1:8081/dashboard with live memory, hit rate and an estimated-savings figure
  • Fail-open — if the engine is unreachable, your function simply runs
import fastcache_ai as fc

fc.dashboard(open_browser=True)   # live console
fc.stats()                        # engine, L1 and client telemetry
fc.info()                         # everything needed to diagnose a problem

Configuration

Zero configuration is a supported configuration. Common overrides:

Variable Purpose Default
FASTCACHE_OFFHEAP_MAX Native memory budget 2g
FASTCACHE_DEFAULT_TTL TTL when the decorator omits one 15m
FASTCACHE_METRICS_PORT Console port (off disables) 8081
FASTCACHE_L1_TTL Local hot-key cache window, seconds 5.0
FASTCACHE_HEARTBEAT_TIMEOUT Orphan-reaping window (0 disables) 40s

Status

Pre-release. Single-node, non-durable and unauthenticated — it binds to loopback and is not a replacement for Redis where you need replication, failover or persistence.

Full documentation, design notes and source: github.com/adi407/fast_cache

Apache 2.0 licensed.

Metadata

Release files for fastcache-ai 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastcache-ai 1.1.0
File Size Uploaded
fastcache_ai-1.1.0.tar.gz 143.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastcache-ai 1.1.0
File Interpreter ABI Platform
fastcache_ai-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 279.2 kB

Release files / fastcache_ai-1.1.0.tar.gz

Download URL fastcache_ai-1.1.0.tar.gz
Size 143.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e0c3bb447719707716dad34685644a539cda077747b7f0732a776f7f3f3c8337
BLAKE2b-256 checksum
How to use checksums
5990a5691c3613609ab867847b5e3886649ec2cfc4abf9da614fc2cb4338bde6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release files / fastcache_ai-1.1.0-py3-none-any.whl

Download URL fastcache_ai-1.1.0-py3-none-any.whl
Size 135.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebfc522e97a91e4eeb9e8dfbb7ec7af89a05c624e1c2b4e7d0823b273bfd45f1
BLAKE2b-256 checksum
How to use checksums
483c190563ef384d6cd8631bbf5cc61ebdad5b46d57dd081e5ea5fdc819723d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page