server_cache library

Framework-neutral cache stores, repositories, locks, and typed factories.

Use a Store when you need the low-level backend contract, or wrap one in a Repository when you want TTLs expressed as Duration values, key prefixes, and cache instrumentation. DataCacheManager keeps named stores and their repositories together during application composition.

The package includes in-memory, file, Ormed database, Redis, and no-op stores. Store construction is typed: pair a StoreFactory with its matching StoreConfiguration instead of passing an unstructured configuration map.

final cache = DataCacheManager()
  ..registerStoreFactory(
    'sessions',
    ArrayStoreFactory(),
    const ArrayStoreConfiguration(serialize: true),
  );

final sessions = cache.store('sessions');
await sessions.put('user:42', {'active': true}, const Duration(minutes: 5));

Classes

ArrayLock
An isolate-local lock backed by an in-memory ArrayStore.
ArrayStore
An isolate-local cache store backed by Dart maps.
ArrayStoreConfiguration
Typed options for creating an ArrayStore.
ArrayStoreFactory
Creates isolate-local ArrayStore instances from typed options.
CacheLock
Shared lock behavior for cache-backed lock implementations.
CreateOrmCacheTable
Ormed migration for the table used by OrmCacheStore.
DataCacheManager
Framework-agnostic cache manager for Repository instances.
FileLock
A lock implementation using files to prevent concurrent execution.
FileStore
Implements the Store and LockProvider contracts using files for storage.
FileStoreConfiguration
Typed options for creating a FileStore.
FileStoreFactory
Creates file-backed stores from typed FileStoreConfiguration options.
NullLock
A no-op lock for disabled or non-persistent caching.
NullStore
No-op store for disabled or intentionally non-persistent caching.
NullStoreConfiguration
Typed options for creating a NullStore.
NullStoreFactory
Creates NullStore instances from typed options.
OrmCacheStore
A database-backed cache store built on Ormed's codegen-free table API.
RedisLock
Redis-backed implementation of CacheLock.
RedisStore
Implements cache storage and locking using a Redis server.
RedisStoreConfiguration
Typed options for creating a RedisStore.
RedisStoreFactory
Creates Redis-backed stores from typed RedisStoreConfiguration options.
RepositoryEventCallbacks
Optional instrumentation callbacks emitted by a cache repository.
RepositoryImpl
Prefixing and instrumentation implementation of the Repository contract.
StoreConfiguration
Typed configuration for a cache store.
StoreFactory<T extends StoreConfiguration>
Creates a Store from typed options.
TaggableStore
Mixin-like base class that exposes tag-scoped cache repositories.
TaggedCache
A Repository whose keys are scoped by a TagSet namespace.
TagSet
Tracks version identifiers for a group of cache invalidation tags.

Typedefs

DataCacheCallbacksBuilder = RepositoryEventCallbacks? Function(String storeName)
Builds repository callbacks for a specific configured store.