UNPKG

@clickup/ent-framework

Version:

A PostgreSQL graph-database-alike library with microsharding and row-level security

42 lines 1.86 kB
import type { VC } from "./VC"; declare const OPS: readonly ["loadNullable", "loadByNullable", "selectBy", "select", "count", "exists"]; export type AnyClass = new (...args: never[]) => unknown; type Op = (typeof OPS)[number]; /** * Caches Ents loaded by a particular VC. I.e. the same query running for the * same VC twice will quickly return the same Ents. This is typically enabled on * web servers only, to deliver the fastest UI response. */ export declare class QueryCache { private maxQueries?; private byEntClass?; readonly whyOff?: string; /** * Creates the QueryCache object. It enable caching only if VCWithQueryCache * was manually added to the VC by the user, otherwise caching is a no-op. */ constructor(vc: VC); /** * Saves a Promise to the cache slot for `op`. If this Promise rejects, the * slot will automatically be cleared (we don't cache rejected Promises to not * have a risk of caching a transient DB error). */ set(EntClass: AnyClass, op: Op, key: string, value: Promise<unknown> | undefined): this; /** * Deletes cache slots or keys for an Ent. If key is null, skips the deletion. * If key is undefined (i.e. not passed), then deletes all slots. */ delete(EntClass: AnyClass, ops: readonly Op[], key?: string | null): this; /** * This method is non-async on intent. We store Promises in the cache, not end * values, because we want the code to join awaiting an ongoing operation in * case it's inflight already. */ get<TValue>(EntClass: AnyClass, op: Op, key: string): Promise<TValue> | undefined; /** * Read-through caching pattern. */ through<TValue>(EntClass: AnyClass, op: Op, key: string, creator: () => Promise<TValue>): Promise<TValue>; } export {}; //# sourceMappingURL=QueryCache.d.ts.map