cache.ts — drizzle-orm Source File
Architecture documentation for cache.ts, a typescript file in the drizzle-orm codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 44f92f64_5c49_a0a8_3c18_2e6651af97f8["cache.ts"] ce81fb60_5bfe_1801_89bb_8ae88028a0a7["types.ts"] 44f92f64_5c49_a0a8_3c18_2e6651af97f8 --> ce81fb60_5bfe_1801_89bb_8ae88028a0a7 1df08b50_d0c9_9907_3375_c15cb3325c69["redis"] 44f92f64_5c49_a0a8_3c18_2e6651af97f8 --> 1df08b50_d0c9_9907_3375_c15cb3325c69 363fdd67_2503_7ef7_e1f3_a1ef31694431["index.ts"] 44f92f64_5c49_a0a8_3c18_2e6651af97f8 --> 363fdd67_2503_7ef7_e1f3_a1ef31694431 27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"] 44f92f64_5c49_a0a8_3c18_2e6651af97f8 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426 6edbc86d_00ec_e1a9_d845_ab84f4882062["index.ts"] 44f92f64_5c49_a0a8_3c18_2e6651af97f8 --> 6edbc86d_00ec_e1a9_d845_ab84f4882062 style 44f92f64_5c49_a0a8_3c18_2e6651af97f8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { Redis } from '@upstash/redis';
import type { MutationOption } from '~/cache/core/index.ts';
import { Cache } from '~/cache/core/index.ts';
import { entityKind, is } from '~/entity.ts';
import { OriginalName, Table } from '~/index.ts';
import type { CacheConfig } from '../core/types.ts';
const getByTagScript = `
local tagsMapKey = KEYS[1] -- tags map key
local tag = ARGV[1] -- tag
local compositeTableName = redis.call('HGET', tagsMapKey, tag)
if not compositeTableName then
return nil
end
local value = redis.call('HGET', compositeTableName, tag)
return value
`;
const onMutateScript = `
local tagsMapKey = KEYS[1] -- tags map key
local tables = {} -- initialize tables array
local tags = ARGV -- tags array
for i = 2, #KEYS do
tables[#tables + 1] = KEYS[i] -- add all keys except the first one to tables
end
if #tags > 0 then
for _, tag in ipairs(tags) do
if tag ~= nil and tag ~= '' then
local compositeTableName = redis.call('HGET', tagsMapKey, tag)
if compositeTableName then
redis.call('HDEL', compositeTableName, tag)
end
end
end
redis.call('HDEL', tagsMapKey, unpack(tags))
end
local keysToDelete = {}
if #tables > 0 then
local compositeTableNames = redis.call('SUNION', unpack(tables))
for _, compositeTableName in ipairs(compositeTableNames) do
keysToDelete[#keysToDelete + 1] = compositeTableName
end
for _, table in ipairs(tables) do
keysToDelete[#keysToDelete + 1] = table
end
redis.call('DEL', unpack(keysToDelete))
end
`;
type Script = ReturnType<Redis['createScript']>;
type ExpireOptions = 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';
export class UpstashCache extends Cache {
// ... (154 more lines)
Domain
Subdomains
Functions
Classes
Types
Dependencies
- entity.ts
- index.ts
- index.ts
- redis
- types.ts
Source
Frequently Asked Questions
What does cache.ts do?
cache.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, RelationalQuery subdomain.
What functions are defined in cache.ts?
cache.ts defines 1 function(s): upstashCache.
What does cache.ts depend on?
cache.ts imports 5 module(s): entity.ts, index.ts, index.ts, redis, types.ts.
Where is cache.ts in the architecture?
cache.ts is located at drizzle-orm/src/cache/upstash/cache.ts (domain: DrizzleORM, subdomain: RelationalQuery, directory: drizzle-orm/src/cache/upstash).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free