singlestore-cache.ts — drizzle-orm Source File
Architecture documentation for singlestore-cache.ts, a typescript file in the drizzle-orm codebase. 6 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 366a8840_7045_c01f_5bc2_0e3563a812f0["singlestore-cache.ts"] 690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"] 366a8840_7045_c01f_5bc2_0e3563a812f0 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031 1887ab54_ea90_d248_26a5_4f0e40379db4["core"] 366a8840_7045_c01f_5bc2_0e3563a812f0 --> 1887ab54_ea90_d248_26a5_4f0e40379db4 d1b6cd91_8772_b4c9_66e1_10ab8d57e474["types"] 366a8840_7045_c01f_5bc2_0e3563a812f0 --> d1b6cd91_8772_b4c9_66e1_10ab8d57e474 b4539857_26bc_b042_0719_5e529c80f1b4["singlestore-core"] 366a8840_7045_c01f_5bc2_0e3563a812f0 --> b4539857_26bc_b042_0719_5e529c80f1b4 1fec5f3c_6c99_322c_4189_0006f171f3de["keyv"] 366a8840_7045_c01f_5bc2_0e3563a812f0 --> 1fec5f3c_6c99_322c_4189_0006f171f3de 8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"] 366a8840_7045_c01f_5bc2_0e3563a812f0 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686 f8cac0b9_5170_b142_659b_035baf0c8931["singlestore.test.ts"] f8cac0b9_5170_b142_659b_035baf0c8931 --> 366a8840_7045_c01f_5bc2_0e3563a812f0 style 366a8840_7045_c01f_5bc2_0e3563a812f0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { eq, getTableName, is, sql, Table } from 'drizzle-orm';
import type { MutationOption } from 'drizzle-orm/cache/core';
import { Cache } from 'drizzle-orm/cache/core';
import type { CacheConfig } from 'drizzle-orm/cache/core/types';
import {
alias,
boolean,
int,
json,
serial,
type SingleStoreDatabase,
singlestoreTable,
text,
timestamp,
} from 'drizzle-orm/singlestore-core';
import Keyv from 'keyv';
import { beforeEach, describe, expect, test, vi } from 'vitest';
// eslint-disable-next-line drizzle-internal/require-entity-kind
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] ?? [];
// ... (331 more lines)
Domain
Subdomains
Functions
Dependencies
- core
- drizzle-orm
- keyv
- singlestore-core
- types
- vitest
Source
Frequently Asked Questions
What does singlestore-cache.ts do?
singlestore-cache.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, QueryBuilders subdomain.
What functions are defined in singlestore-cache.ts?
singlestore-cache.ts defines 1 function(s): tests.
What does singlestore-cache.ts depend on?
singlestore-cache.ts imports 6 module(s): core, drizzle-orm, keyv, singlestore-core, types, vitest.
What files import singlestore-cache.ts?
singlestore-cache.ts is imported by 1 file(s): singlestore.test.ts.
Where is singlestore-cache.ts in the architecture?
singlestore-cache.ts is located at integration-tests/tests/singlestore/singlestore-cache.ts (domain: DrizzleORM, subdomain: QueryBuilders, directory: integration-tests/tests/singlestore).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free