Skip to content

PlatformCacheInterceptor

@tsed/platform-cache

Usage

typescript
import { PlatformCacheInterceptor } from "@tsed/platform-cache";

See /packages/platform/platform-cache/src/types/interceptors/PlatformCacheInterceptor.ts.

Overview

ts
class PlatformCacheInterceptor implements InterceptorMethods {
    protected cache: PlatformCache;
    protected logger: Logger;
    protected prefix: string;
    protected blacklist: string[];
    intercept(context: InterceptorContext<any, PlatformCacheOptions>, next: InterceptorNext): unknown;
    canRefreshInBackground(key: string, { refreshThreshold, ttl }: {
        refreshThreshold?: number;
        ttl: any;
    }, next: Function): Promise<void>;
    cacheMethod(context: InterceptorContext<any, PlatformCacheOptions>, next: InterceptorNext): Promise<any>;
    cacheResponse(context: InterceptorContext<any, PlatformCacheOptions>, next: InterceptorNext): Promise<any>;
    protected getArgs(context: InterceptorContext<unknown, PlatformCacheOptions>): any;
    protected getOptions(context: InterceptorContext<any, PlatformCacheOptions>): {
        key: string;
        refreshThreshold: number | undefined;
        ttl: import("../services/PlatformCache.js").Ttl | undefined;
        type: any;
        args: any;
        collectionType: any;
        keyArgs: string;
        canCache: ((item: any) => boolean) | undefined;
        $ctx: any;
    };
    protected hasKeyInQueue(key: string): Promise<boolean>;
    protected addKeyToQueue(key: string): Promise<void>;
    protected deleteKeyFromQueue(key: string): Promise<void>;
    protected sendResponse(cachedObject: PlatformCachedObject, $ctx: BaseContext): any;
}

protected cache

ts
protected cache: PlatformCache;

protected logger

ts
protected logger: Logger;

protected prefix

ts
protected prefix: string;

protected blacklist

ts
protected blacklist: string[];

intercept

ts
intercept(context: InterceptorContext<any, PlatformCacheOptions>, next: InterceptorNext): unknown;

canRefreshInBackground

ts
canRefreshInBackground(key: string, { refreshThreshold, ttl }: {
     refreshThreshold?: number;
     ttl: any;
 }, next: Function): Promise<void>;

cacheMethod

ts
cacheMethod(context: InterceptorContext<any, PlatformCacheOptions>, next: InterceptorNext): Promise<any>;

cacheResponse

ts
cacheResponse(context: InterceptorContext<any, PlatformCacheOptions>, next: InterceptorNext): Promise<any>;

protected getArgs

ts
protected getArgs(context: InterceptorContext<unknown, PlatformCacheOptions>): any;

protected getOptions

ts
protected getOptions(context: InterceptorContext<any, PlatformCacheOptions>): {
     key: string;
     refreshThreshold: number | undefined;
     ttl: import("../services/PlatformCache.js").Ttl | undefined;
     type: any;
     args: any;
     collectionType: any;
     keyArgs: string;
     canCache: ((item: any) => boolean) | undefined;
     $ctx: any;
 };

protected hasKeyInQueue

ts
protected hasKeyInQueue(key: string): Promise<boolean>;

protected addKeyToQueue

ts
protected addKeyToQueue(key: string): Promise<void>;

protected deleteKeyFromQueue

ts
protected deleteKeyFromQueue(key: string): Promise<void>;

protected sendResponse

ts
protected sendResponse(cachedObject: PlatformCachedObject, $ctx: BaseContext): any;

Released under the MIT License.