Import
import { FunctionCallResultCache } from '@rs-x/core';API Reference
Cache utility service for function-call results. Entries are keyed by context object and function-call identity (function name + arguments). When you create a cache entry, call dispose() on that entry when finished, to release references and prevent memory leaks.
import { FunctionCallResultCache } from '@rs-x/core';import {
InjectionContainer,
RsXCoreInjectionTokens,
RsXCoreModule,
type IFunctionCallResultCache,
type IFunctionCallIndexFactory,
} from '@rs-x/core';
await InjectionContainer.load(RsXCoreModule);
const cache = InjectionContainer.get<IFunctionCallResultCache>(
RsXCoreInjectionTokens.IFunctionCallResultCache,
);
const indexFactory = InjectionContainer.get<IFunctionCallIndexFactory>(
RsXCoreInjectionTokens.IFunctionCallIndexFactory,
);
const context = {
sum(a: number, b: number) {
return a + b;
},
};import {
Inject,
RsXCoreInjectionTokens,
type IFunctionCallResultCache,
} from '@rs-x/core';
class SumService {
constructor(
@Inject(RsXCoreInjectionTokens.IFunctionCallResultCache)
private readonly resultCache: IFunctionCallResultCache,
) {}
}4 members in this class.
constructor(
@Inject(RsXCoreInjectionTokens.IFunctionCallIndexFactory) functionCallIndexFactory: IFunctionCallIndexFactory
)Parameters
public create(
context: unknown,
result: IFunctionCallResult
): IFunctionCallResultCacheEntryParameters
public get(
context: unknown,
index: IDisposableFunctionCallIndex
): IFunctionCallResultCacheEntry | undefinedParameters
Returns
IFunctionCallResultCacheEntry | undefined
public has(
context: unknown,
index: IDisposableFunctionCallIndex
): booleanParameters
Returns
boolean