Entity

    Interface IEntityGenericCacher<TFields, TIDField>

    A generic cacher stores and loads key-value pairs. It also supports negative caching - it stores the absence of keys that don't exist in the backing datastore. It is also responsible for cache key creation.

    interface IEntityGenericCacher<
        TFields extends Record<string, any>,
        TIDField extends keyof TFields,
    > {
        cacheDBMissesAsync(keys: readonly string[]): Promise<void>;
        cacheManyAsync(
            objectMap: ReadonlyMap<string, Readonly<TFields>>,
        ): Promise<void>;
        invalidateManyAsync(keys: readonly string[]): Promise<void>;
        loadManyAsync(
            keys: readonly string[],
        ): Promise<ReadonlyMap<string, CacheLoadResult<TFields>>>;
        makeCacheKeyForStorage<
            TLoadKey extends
                IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
            TSerializedLoadValue,
            TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
        >(
            key: TLoadKey,
            value: TLoadValue,
        ): string;
        makeCacheKeysForInvalidation<
            TLoadKey extends
                IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
            TSerializedLoadValue,
            TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
        >(
            key: TLoadKey,
            value: TLoadValue,
        ): readonly string[];
    }

    Type Parameters

    • TFields extends Record<string, any>
    • TIDField extends keyof TFields

    Implemented by

    Index

    Methods

    • Negatively-cache specified keys. Subsequent loads for these keys (without calling invalidate) may return a negative CacheLoadResult

      Parameters

      • keys: readonly string[]

        keys to cache negatively

      Returns Promise<void>

    • Cache many objects for specified keys.

      Parameters

      • objectMap: ReadonlyMap<string, Readonly<TFields>>

        map from cache key to object to cache for key

      Returns Promise<void>

    • Invalidate specified keys in cache. Subsequent loads for these keys may return a cache miss.

      Parameters

      • keys: readonly string[]

        keys to invalidate

      Returns Promise<void>

    MMNEPVFCICPMFPCPTTAAATR