Skip to content

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.

const cached = await cache.get(userKey);
await cache.set(userKey, user.toJSON(), {
ttl: 30_000,
isNewer: isCacheNewer,
});
await cache.delete(userKey);

T = unknown

Value shape stored by this cache adapter.

delete(key): Promise<void>

Defined in: packages/ddd-core/application/ports/cache.port.ts:45

Removes key when present.

string

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.

string

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.

string

T

CacheSetOptions

Promise<void>