sqlite-common-cache.ts — drizzle-orm Source File
Architecture documentation for sqlite-common-cache.ts, a typescript file in the drizzle-orm codebase. 6 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 7f26f618_3381_4763_89e6_6503ea1e3ebd["sqlite-common-cache.ts"] 690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"] 7f26f618_3381_4763_89e6_6503ea1e3ebd --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031 1887ab54_ea90_d248_26a5_4f0e40379db4["core"] 7f26f618_3381_4763_89e6_6503ea1e3ebd --> 1887ab54_ea90_d248_26a5_4f0e40379db4 d1b6cd91_8772_b4c9_66e1_10ab8d57e474["types"] 7f26f618_3381_4763_89e6_6503ea1e3ebd --> d1b6cd91_8772_b4c9_66e1_10ab8d57e474 25248a9d_ba06_2b33_4421_8575da2f9c34["sqlite-core"] 7f26f618_3381_4763_89e6_6503ea1e3ebd --> 25248a9d_ba06_2b33_4421_8575da2f9c34 1fec5f3c_6c99_322c_4189_0006f171f3de["keyv"] 7f26f618_3381_4763_89e6_6503ea1e3ebd --> 1fec5f3c_6c99_322c_4189_0006f171f3de 8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"] 7f26f618_3381_4763_89e6_6503ea1e3ebd --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686 0cd869b6_b82b_1b69_7612_7b75f8f371d3["d1.test.ts"] 0cd869b6_b82b_1b69_7612_7b75f8f371d3 --> 7f26f618_3381_4763_89e6_6503ea1e3ebd 5d37242e_76a0_a160_94b8_1a6a235a6008["libsql.test.ts"] 5d37242e_76a0_a160_94b8_1a6a235a6008 --> 7f26f618_3381_4763_89e6_6503ea1e3ebd 96b7f482_cbb7_44ab_3fc0_369276a1c78c["sqlite-proxy.test.ts"] 96b7f482_cbb7_44ab_3fc0_369276a1c78c --> 7f26f618_3381_4763_89e6_6503ea1e3ebd style 7f26f618_3381_4763_89e6_6503ea1e3ebd 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, type BaseSQLiteDatabase, integer, sqliteTable, text } from 'drizzle-orm/sqlite-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] ?? [];
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);
// ... (321 more lines)
Domain
Subdomains
Functions
Types
Dependencies
- core
- drizzle-orm
- keyv
- sqlite-core
- types
- vitest
Imported By
Source
Frequently Asked Questions
What does sqlite-common-cache.ts do?
sqlite-common-cache.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, SQLDialects subdomain.
What functions are defined in sqlite-common-cache.ts?
sqlite-common-cache.ts defines 1 function(s): tests.
What does sqlite-common-cache.ts depend on?
sqlite-common-cache.ts imports 6 module(s): core, drizzle-orm, keyv, sqlite-core, types, vitest.
What files import sqlite-common-cache.ts?
sqlite-common-cache.ts is imported by 3 file(s): d1.test.ts, libsql.test.ts, sqlite-proxy.test.ts.
Where is sqlite-common-cache.ts in the architecture?
sqlite-common-cache.ts is located at integration-tests/tests/sqlite/sqlite-common-cache.ts (domain: DrizzleORM, subdomain: SQLDialects, directory: integration-tests/tests/sqlite).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free