UNPKG

2.17 kBTypeScriptView Raw
1import { QueryResultCache } from "./QueryResultCache";
2import { QueryResultCacheOptions } from "./QueryResultCacheOptions";
3import { Connection } from "../connection/Connection";
4import { QueryRunner } from "../query-runner/QueryRunner";
5/**
6 * Caches query result into Redis database.
7 */
8export declare class RedisQueryResultCache implements QueryResultCache {
9 protected connection: Connection;
10 /**
11 * Redis module instance loaded dynamically.
12 */
13 protected redis: any;
14 /**
15 * Connected redis client.
16 */
17 protected client: any;
18 /**
19 * Type of the Redis Client (redis or ioredis).
20 */
21 protected clientType: "redis" | "ioredis" | "ioredis/cluster";
22 constructor(connection: Connection, clientType: "redis" | "ioredis" | "ioredis/cluster");
23 /**
24 * Creates a connection with given cache provider.
25 */
26 connect(): Promise<void>;
27 /**
28 * Disconnects the connection
29 */
30 disconnect(): Promise<void>;
31 /**
32 * Creates table for storing cache if it does not exist yet.
33 */
34 synchronize(queryRunner: QueryRunner): Promise<void>;
35 /**
36 * Caches given query result.
37 * Returns cache result if found.
38 * Returns undefined if result is not cached.
39 */
40 getFromCache(options: QueryResultCacheOptions, queryRunner?: QueryRunner): Promise<QueryResultCacheOptions | undefined>;
41 /**
42 * Checks if cache is expired or not.
43 */
44 isExpired(savedCache: QueryResultCacheOptions): boolean;
45 /**
46 * Stores given query result in the cache.
47 */
48 storeInCache(options: QueryResultCacheOptions, savedCache: QueryResultCacheOptions, queryRunner?: QueryRunner): Promise<void>;
49 /**
50 * Clears everything stored in the cache.
51 */
52 clear(queryRunner?: QueryRunner): Promise<void>;
53 /**
54 * Removes all cached results by given identifiers from cache.
55 */
56 remove(identifiers: string[], queryRunner?: QueryRunner): Promise<void>;
57 /**
58 * Removes a single key from redis database.
59 */
60 protected deleteKey(key: string): Promise<void>;
61 /**
62 * Loads redis dependency.
63 */
64 protected loadRedis(): any;
65}