TestGlobalCache Class — drizzle-orm Architecture
Architecture documentation for the TestGlobalCache class in singlestore-cache.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 58fc1702_28d9_32ba_a090_d4044bb1b841["TestGlobalCache"] 366a8840_7045_c01f_5bc2_0e3563a812f0["singlestore-cache.ts"] 58fc1702_28d9_32ba_a090_d4044bb1b841 -->|defined in| 366a8840_7045_c01f_5bc2_0e3563a812f0 a4d323dd_3a87_43f4_f14a_51bd2e3d27ee["constructor()"] 58fc1702_28d9_32ba_a090_d4044bb1b841 -->|method| a4d323dd_3a87_43f4_f14a_51bd2e3d27ee 0cdbc96c_b5ee_1eb5_fb59_7ed31a857d34["strategy()"] 58fc1702_28d9_32ba_a090_d4044bb1b841 -->|method| 0cdbc96c_b5ee_1eb5_fb59_7ed31a857d34 18bde7eb_5fc9_2ea7_d2a4_bf8e55a7cbfe["get()"] 58fc1702_28d9_32ba_a090_d4044bb1b841 -->|method| 18bde7eb_5fc9_2ea7_d2a4_bf8e55a7cbfe f05ed177_b65c_201b_b57c_661da19ad632["put()"] 58fc1702_28d9_32ba_a090_d4044bb1b841 -->|method| f05ed177_b65c_201b_b57c_661da19ad632 6abed97f_be94_27e5_491f_eeca6b84e3cb["onMutate()"] 58fc1702_28d9_32ba_a090_d4044bb1b841 -->|method| 6abed97f_be94_27e5_491f_eeca6b84e3cb
Relationship Graph
Source Code
integration-tests/tests/singlestore/singlestore-cache.ts lines 20–78
export class TestGlobalCache extends Cache {
private globalTtl: number = 1000;
private usedTablesPerKey: Record<string, string[]> = {};
constructor(private kv: Keyv = new Keyv()) {
super();
}
override strategy(): 'explicit' | 'all' {
return 'all';
}
override async get(key: string, _tables: string[], _isTag: boolean): Promise<any[] | undefined> {
const res = await this.kv.get(key) ?? undefined;
return res;
}
override async put(
key: string,
response: any,
tables: string[],
isTag: boolean,
config?: CacheConfig,
): Promise<void> {
await this.kv.set(key, response, config ? config.ex : this.globalTtl);
for (const table of tables) {
const keys = this.usedTablesPerKey[table];
if (keys === undefined) {
this.usedTablesPerKey[table] = [key];
} else {
keys.push(key);
}
}
}
override async onMutate(params: MutationOption): Promise<void> {
const tagsArray = params.tags ? Array.isArray(params.tags) ? params.tags : [params.tags] : [];
const tablesArray = params.tables ? Array.isArray(params.tables) ? params.tables : [params.tables] : [];
const keysToDelete = new Set<string>();
for (const table of tablesArray) {
const tableName = is(table, Table) ? getTableName(table) : table as string;
const keys = this.usedTablesPerKey[tableName] ?? [];
for (const key of keys) keysToDelete.add(key);
}
if (keysToDelete.size > 0 || tagsArray.length > 0) {
for (const tag of tagsArray) {
await this.kv.delete(tag);
}
for (const key of keysToDelete) {
await this.kv.delete(key);
for (const table of tablesArray) {
const tableName = is(table, Table) ? getTableName(table) : table as string;
this.usedTablesPerKey[tableName] = [];
}
}
}
}
}
Domain
Source
Frequently Asked Questions
What is the TestGlobalCache class?
TestGlobalCache is a class in the drizzle-orm codebase, defined in integration-tests/tests/singlestore/singlestore-cache.ts.
Where is TestGlobalCache defined?
TestGlobalCache is defined in integration-tests/tests/singlestore/singlestore-cache.ts at line 20.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free