PlatformCache
@tsed/platform-cache
Usage
typescript
import { PlatformCache } from "@tsed/platform-cache";
See /packages/platform/platform-cache/src/types/services/PlatformCache.ts.
Overview
ts
class PlatformCache {
protected settings: Configuration;
protected injector: InjectorService;
protected logger: Logger;
get cache(): CacheManager | undefined;
$onInit(): Promise<void>;
getKeysOf(target: Type<any>, propertyKey: string | symbol): Promise<string[]>;
disabled(): boolean;
defaultKeyResolver(): (args: any[], ctx?: any) => string;
defaultTtl(): Ttl;
calculateTTL(result?: any, currentTtl?: Ttl): number;
ttl(key: string): Promise<void> | Promise<number>;
wrap<T>(key: string, fetch: () => Promise<T>, ttl?: number): Promise<T>;
get<T>(key: string, options?: JsonDeserializerOptions): Promise<T | undefined>;
set<T>(key: string, value: any, options?: CachingConfig<T>): Promise<T | undefined>;
getCachedObject(key: string): Promise<PlatformCachedObject | undefined>;
setCachedObject(key: string, data: any, opts: {
ttl: number;
} & Record<string, any>): Promise<void>;
del(key: string): Promise<void>;
reset(): Promise<void>;
keys(...args: any[]): Promise<string[]>;
deleteKeys(patterns: string): Promise<string[]>;
getMatchingKeys(patterns: string): Promise<string[]>;
deleteMatchingKeys(patterns: string): Promise<string[]>;
refresh(callback: () => Promise<any> | any): any;
isForceRefresh(): boolean;
protected createCacheManager(settings: PlatformCacheSettings): Promise<MultiCache | import("cache-manager").MemoryCache>;
}
protected settings
ts
protected settings: Configuration;
protected injector
ts
protected injector: InjectorService;
protected logger
ts
protected logger: Logger;
get cache
ts
get cache(): CacheManager | undefined;
$onInit
ts
$onInit(): Promise<void>;
getKeysOf
ts
getKeysOf(target: Type<any>, propertyKey: string | symbol): Promise<string[]>;
disabled
ts
disabled(): boolean;
defaultKeyResolver
ts
defaultKeyResolver(): (args: any[], ctx?: any) => string;
defaultTtl
ts
defaultTtl(): Ttl;
calculateTTL
ts
calculateTTL(result?: any, currentTtl?: Ttl): number;
ttl
ts
ttl(key: string): Promise<void> | Promise<number>;
wrap
ts
wrap<T>(key: string, fetch: () => Promise<T>, ttl?: number): Promise<T>;
get
ts
get<T>(key: string, options?: JsonDeserializerOptions): Promise<T | undefined>;
set
ts
set<T>(key: string, value: any, options?: CachingConfig<T>): Promise<T | undefined>;
getCachedObject
ts
getCachedObject(key: string): Promise<PlatformCachedObject | undefined>;
setCachedObject
ts
setCachedObject(key: string, data: any, opts: {
ttl: number;
} & Record<string, any>): Promise<void>;
del
ts
del(key: string): Promise<void>;
reset
ts
reset(): Promise<void>;
keys
ts
keys(...args: any[]): Promise<string[]>;
deleteKeys
ts
deleteKeys(patterns: string): Promise<string[]>;
getMatchingKeys
ts
getMatchingKeys(patterns: string): Promise<string[]>;
Use micromatch instead native patterns. Use this method if the native store method doesn't support glob patterns
deleteMatchingKeys
ts
deleteMatchingKeys(patterns: string): Promise<string[]>;
refresh
ts
refresh(callback: () => Promise<any> | any): any;
isForceRefresh
ts
isForceRefresh(): boolean;
protected createCacheManager
ts
protected createCacheManager(settings: PlatformCacheSettings): Promise<MultiCache | import("cache-manager").MemoryCache>;