createPartitionedCacheKeyFactory
Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.
createPartitionedCacheKeyFactory(
options):CacheKeyFactory
Defined in: packages/pipeline-cache/src/helpers/cache-key.ts:102
Builds a cache key that partitions every dimension capable of changing an authorized response.
The key includes tenant, principal, optional permission scope, request type, and a SHA-256 digest of the request payload. This keeps raw request data out of cache key listings while preventing authorized responses from being shared across callers with different security context.
Use this helper when a cache hit can bypass authorization or response filtering performed inside the handler.
Parameters
Section titled “Parameters”options
Section titled “options”Resolvers and fail-closed requirements for key partitioning.
Returns
Section titled “Returns”A CacheKeyFactory suitable for CacheBehaviorOptions.key.
Throws
Section titled “Throws”When requireScope is not false and no scope resolver is given.
Throws
Section titled “Throws”(from the returned factory) When a required tenant, principal or scope is absent.
Examples
Section titled “Examples”Per principal, tenant-aware, invalidated when roles change
class GetUsersHandler { @pipeline.wrap({ kind: 'query' }, [CacheBehavior, { key: createPartitionedCacheKeyFactory({ principal: (ctx) => ctx.items.get('currentUserId') as string | undefined, scope: (ctx) => ctx.items.get('capabilityVersion') as string | undefined, }), }]) async handle(query: GetUsersQuery) {}}Public reference data, identical for every caller
createPartitionedCacheKeyFactory({ principal: () => 'public', requirePrincipal: false, requireTenant: false, requireScope: false,});