CacheCore is a reusable caching layer for SaaS backends with support for namespacing, TTL, tag-based invalidation, metrics, and tenant-aware keys.
It is intentionally positioned as a structured cache library plus a reference admin API, not as a thin Redis wrapper.
This repository is meant to be a real backend caching foundation, with explicit policies and operational behavior.
For repo routing, boundary guidance, release checks, and machine-readable
catalog surfaces across the Saazip SaaS repos, use
saasctl.
CacheCore exists for teams that want caching to stay predictable as systems get larger.
- enforce consistent key construction
- scope keys by namespace and tenant
- make invalidation explicit instead of magical
- support tag-based invalidation
- expose metrics that help operating the cache
- keep the core usable without forcing a specific application shape
Typical use cases:
- caching aggregate reads
- tenant-scoped response caches
- schema and configuration lookups
- temporary read-through acceleration
- not automatic ORM caching
- not a generic abstraction over every cache backend in v1
- not a substitute for authoritative storage
cp .env.example .env
docker compose up -d redis
pnpm install
pnpm dev:admin-apiLocal services:
- Admin API:
http://localhost:3040 - Redis:
localhost:6382
Operational defaults:
/healthand/readystay open for probes/v1/*can be protected withAPI_KEYS- requests may send
x-request-id, which is echoed back or generated - the SDK supports stale-while-revalidate through
remember()andgetWithMetadata()
You can reuse CacheCore in three ways:
This is the default adoption path for CacheCore.
- your product uses
@saazip/cache-coredirectly - CacheCore provides namespacing, invalidation rules, and metrics primitives
- useful when caching should stay close to application reads and writes
Use the admin API when you want a standard operational surface for warming, invalidating, or inspecting cache behavior.
- useful for shared platform operations
- good when multiple services use the same Redis-backed cache conventions
Keep CacheCore generic and define product-specific keys, policies, and tag strategy in the consuming application.
- CacheCore owns cache mechanics
- your product owns which reads are cached and when they are invalidated
- useful when you want reuse without building a one-size-fits-all cache abstraction
CacheCore is library-first.
Primary package:
@saazip/cache-core
Supporting published packages used by the SDK:
@saazip/cache-core-contracts@saazip/cache-core-domain@saazip/cache-core-metrics
Repo-local pieces that stay internal for now:
- admin API application
- Redis adapter package
- testing helpers
apps/
admin-api/ Reference operational API for invalidation and metrics
packages/
core/ Key policy, namespacing, and invalidation model
contracts/ Public HTTP contracts
metrics/ Metric names and helpers
sdk/ Public package published as @saazip/cache-core
adapters/redis/ Official Redis adapter
testing/ Fixtures for downstream adopters
docs/ Architecture, concepts, operations, ADRs
examples/ Reference integration examples
docker/ Local infrastructure configIf you want to contribute, start here:
- Read this README for product boundaries.
- Read docs/README.md for the docs map.
- Read CONTRIBUTING.md before changing cache semantics or invalidation behavior.
Useful commands:
pnpm run ci
pnpm dev:admin-api
pnpm example:http-cache
pnpm test:suiteContribution areas that add value early:
- Redis adapter hardening
- invalidation strategy and tag index behavior
- metrics and observability exports
- docs, examples, and operational guidance
- Contributing guide
- Security policy
- Architecture and concepts
- API reference
- Compose with the Saazip infra suite
- Release checklist
- HTTP cache example
- Suite e2e example
- Node
24.x - pnpm
10.33.x - Redis
7+for the official adapter - npm package available as
@saazip/cache-core
@saazip/queueflowcan cache metrics and read models, never job truth@saazip/eventflowcan cache schema lookups and aggregate reads@saazip/webhook-corecan cache endpoint and subscription snapshots
Use pnpm test:suite to run the automated local composition check for:
eventflow -> queueflow -> webhook-core -> cache-core- local dependency containers
- live
readyprobes before the end-to-end flow starts
Apache-2.0