Class EntitySecondaryCacheLoader<TLoadParams, TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>Abstract

A secondary cache loader allows for arbitrary cache keying for load params, which are a set of params used to load a single entity field object.

Note that this cache cannot be automatically invalidated like other entity caches so it must be manually invalidated when the underlying data of a cache key could be stale.

This is most commonly used to further optimize hot paths that cannot make use of normal entity cache loading due to use of a non-unique-field-based EntityLoader method like loadManyByFieldEqualityConjunctionAsync or loadManyByRawWhereClauseAsync.

Type Parameters

  • TLoadParams

  • TFields extends object

  • TID extends NonNullable<TFields[TSelectedFields]>

  • TViewerContext extends ViewerContext

  • TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>

  • TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>

  • TSelectedFields extends keyof TFields = keyof TFields

Hierarchy

  • EntitySecondaryCacheLoader

Constructors

  • Type Parameters

    • TLoadParams

    • TFields extends object

    • TID extends {}

    • TViewerContext extends ViewerContext<TViewerContext>

    • TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields, TEntity>

    • TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields, TPrivacyPolicy>

    • TSelectedFields extends string | number | symbol = keyof TFields

    Parameters

    • secondaryEntityCache: ISecondaryEntityCache<TFields, TLoadParams>
    • entityLoader: EntityLoader<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>

    Returns EntitySecondaryCacheLoader<TLoadParams, TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>

Properties

entityLoader: EntityLoader<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>
secondaryEntityCache: ISecondaryEntityCache<TFields, TLoadParams>

Methods

  • Load through method called to fetch objects when load params objects are not in the cache

    Parameters

    • loadParamsArray: readonly Readonly<TLoadParams>[]

      array of load params objects to load

    Returns Promise<ReadonlyMap<Readonly<Readonly<TLoadParams>>, null | Readonly<TFields>>>

  • Invalidate the cache for objects cached by loadParams.

    Parameters

    • loadParamsArray: readonly Readonly<TLoadParams>[]

      array of load params objects to invalidate

    Returns Promise<void>

  • Load many by load params objects

    Parameters

    • loadParamsArray: readonly Readonly<TLoadParams>[]

      array of loadParams to load through the cache

    Returns Promise<ReadonlyMap<Readonly<TLoadParams>, null | Result<TEntity>>>

Generated using TypeDoc