alepha@docs:~/docs/packages/alepha/cache$
cat database.md | pretty
1 min read
Last commit:

#Alepha - Cache Database

#Installation

Part of the alepha package. Import from alepha/cache/database.

npm install alepha

#Overview

Plugin for Alepha Cache that stores entries in the application's SQL database.

Adds a cache_entries table and a {@link DatabaseCacheProvider} implementation of {@link CacheProvider} that:

  • reads/writes through the framework's ORM (Postgres, SQLite, D1, Bun);
  • exposes an atomic incr() via INSERT ... ON CONFLICT DO UPDATE;
  • filters expired rows on every read (lazy expiration);
  • opportunistically sweeps a small batch of expired rows on writes (configurable via {@link databaseCacheOptions}).

Module is opt-in. Importing this module does not change the default CacheProvider binding — pass provider: DatabaseCacheProvider explicitly to the relevant $cache(...) calls, or rebind globally via alepha.with({ provide: CacheProvider, use: DatabaseCacheProvider }).

#API Reference

#Providers