MCPcopy Index your code
hub / github.com/simstudioai/sim / InMemoryBase64Cache

Class InMemoryBase64Cache

apps/sim/lib/uploads/utils/user-file-base64.server.ts:175–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175class InMemoryBase64Cache implements Base64Cache {
176 private entries = new Map<string, { value: string; expiresAt: number }>()
177
178 async get(file: UserFile): Promise<string | null> {
179 const key = getFileCacheKey(file)
180 const entry = this.entries.get(key)
181 if (!entry) {
182 return null
183 }
184 if (entry.expiresAt <= Date.now()) {
185 this.entries.delete(key)
186 return null
187 }
188 return entry.value
189 }
190
191 async set(file: UserFile, value: string, ttlSeconds: number): Promise<void> {
192 const key = getFileCacheKey(file)
193 const expiresAt = Date.now() + ttlSeconds * 1000
194 this.entries.set(key, { value, expiresAt })
195 }
196}
197
198function createBase64Cache(options: Base64HydrationOptions, logger: Logger): Base64Cache {
199 const redis = getRedisClient()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected