layered-loader
Version:
Data loader with support for caching and fallback data sources
26 lines (25 loc) • 1.56 kB
TypeScript
import type Redis from 'ioredis';
import { GroupLoader } from '../GroupLoader';
import type { CacheEntry, GroupCache, GroupCacheConfiguration } from '../types/DataSources';
import type { GetManyResult } from '../types/SyncDataSources';
import type { RedisCacheConfiguration } from './AbstractRedisCache';
import { AbstractRedisCache } from './AbstractRedisCache';
export interface RedisGroupCacheConfiguration extends RedisCacheConfiguration, GroupCacheConfiguration {
groupTtlInMsecs?: number;
}
export declare class RedisGroupCache<T> extends AbstractRedisCache<RedisGroupCacheConfiguration, T> implements GroupCache<T> {
readonly expirationTimeLoadingGroupedOperation: GroupLoader<number>;
ttlLeftBeforeRefreshInMsecs?: number;
name: string;
constructor(redis: Redis, config?: Partial<RedisGroupCacheConfiguration>);
deleteGroup(group: string): Promise<number | undefined>;
deleteFromGroup(key: string, group: string): Promise<void>;
getFromGroup(key: string, groupId: string): Promise<T | undefined | null>;
getManyFromGroup(keys: string[], groupId: string): Promise<GetManyResult<T>>;
getExpirationTimeFromGroup(key: string, groupId: string): Promise<number | undefined>;
setForGroup(key: string, value: T | null, groupId: string): Promise<void>;
setManyForGroup(entries: readonly CacheEntry<T>[], groupId: string): Promise<unknown>;
resolveKeyWithGroup(key: string, groupId: string, groupIndexKey: string): string;
resolveGroupIndexPrefix(groupId: string): string;
close(): Promise<void>;
}