API Reference

FunctionCallResultCacheclass

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

import { FunctionCallResultCache } from '@rs-x/core';

Example

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;
  },
};

Constructor injection example

import {
  Inject,
  RsXCoreInjectionTokens,
  type IFunctionCallResultCache,
} from '@rs-x/core';

class SumService {
  constructor(
    @Inject(RsXCoreInjectionTokens.IFunctionCallResultCache)
    private readonly resultCache: IFunctionCallResultCache,
  ) {}
}

Members

4 members in this class.

constructor
constructorpublic
constructor(
  @Inject(RsXCoreInjectionTokens.IFunctionCallIndexFactory) functionCallIndexFactory: IFunctionCallIndexFactory
)

Parameters

Name
Type
Required
functionCallIndexFactory
IFunctionCallIndexFactory
required
has
methodpublic
public has(
  context: unknown,
  index: IDisposableFunctionCallIndex
): boolean

Parameters

Name
Type
Required
context
unknown
required

Returns

boolean