ICache
Defined in: packages/ddd-core/application/ports/cache.port.ts:37
Minimal cache port used by DDD repository decorators.
Implementations must store detached/serializable snapshots rather than live
domain aggregates. set() may additionally implement compare-and-set
semantics through CacheSetOptions.isNewer.
Example
Section titled “Example”const cached = await cache.get(userKey);await cache.set(userKey, user.toJSON(), { ttl: 30_000, isNewer: isCacheNewer,});await cache.delete(userKey);Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”T = unknown
Value shape stored by this cache adapter.
Methods
Section titled “Methods”delete()
Section titled “delete()”delete(
key):Promise<void>
Defined in: packages/ddd-core/application/ports/cache.port.ts:45
Removes key when present.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
get(
key):Promise<T|undefined>
Defined in: packages/ddd-core/application/ports/cache.port.ts:39
Returns the cached value, or undefined when the key is absent.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<T | undefined>
set(
key,value,options?):Promise<void>
Defined in: packages/ddd-core/application/ports/cache.port.ts:42
Writes a value under key, optionally with TTL/CAS semantics.
Parameters
Section titled “Parameters”string
T
options?
Section titled “options?”Returns
Section titled “Returns”Promise<void>