AK-21/Graphite-Industrial-Intelligence
0
1import { Redis } from '@upstash/redis';2import type { MutationOption } from "../core/index.js";3import { Cache } from "../core/index.js";4import { entityKind } from "../../entity.js";5import type { CacheConfig } from "../core/types.js";6export declare class UpstashCache extends Cache {7 redis: Redis;8 protected useGlobally?: boolean | undefined;9 static readonly [entityKind]: string;10 /**11 * Prefix for sets which denote the composite table names for each unique table12 *13 * Example: In the composite table set of "table1", you may find14 * `${compositeTablePrefix}table1,table2` and `${compositeTablePrefix}table1,table3`15 */16 private static compositeTableSetPrefix;17 /**18 * Prefix for hashes which map hash or tags to cache values19 */20 private static compositeTablePrefix;21 /**22 * Key which holds the mapping of tags to composite table names23 *24 * Using this tagsMapKey, you can find the composite table name for a given tag25 * and get the cache value for that tag:26 *27 * ```ts28 * const compositeTable = redis.hget(tagsMapKey, 'tag1')29 * console.log(compositeTable) // `${compositeTablePrefix}table1,table2`30 *31 * const cachevalue = redis.hget(compositeTable, 'tag1')32 */33 private static tagsMapKey;34 /**35 * Queries whose auto invalidation is false aren't stored in their respective36 * composite table hashes because those hashes are deleted when a mutation37 * occurs on related tables.38 *39 * Instead, they are stored in a separate hash with the prefix40 * `__nonAutoInvalidate__` to prevent them from being deleted when a mutation41 */42 private static nonAutoInvalidateTablePrefix;43 private luaScripts;44 private internalConfig;45 constructor(redis: Redis, config?: CacheConfig, useGlobally?: boolean | undefined);46 strategy(): "all" | "explicit";47 private toInternalConfig;48 get(key: string, tables: string[], isTag?: boolean, isAutoInvalidate?: boolean): Promise<any[] | undefined>;49 put(key: string, response: any, tables: string[], isTag?: boolean, config?: CacheConfig): Promise<void>;50 onMutate(params: MutationOption): Promise<void>;51 private addTablePrefix;52 private getCompositeKey;53}54export declare function upstashCache({ url, token, config, global }: {55 url: string;56 token: string;57 config?: CacheConfig;58 global?: boolean;59}): UpstashCache;60 