Initial commit: Visigine (Vite client + Express/SQLite backend)
Container-ready via docker/ compose (frontend nginx + backend Node). Compose adjusted for Coolify on the prod server: frontend uses expose:80 (no host binding — host 8080 is taken by the Coolify proxy; Traefik routes visigine.de), backend ALLOWED_ORIGINS=https://visigine.de. Secrets stay in server/.env (git-ignored); see server/.env.example. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
26
server/lib/cache.js
Normal file
26
server/lib/cache.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// Simple in-memory LRU with TTL.
|
||||
// Map preserves insertion order — evict oldest on overflow; refresh on read.
|
||||
const TTL_MS = 60 * 60 * 1000
|
||||
const MAX_ENTRIES = 1000
|
||||
|
||||
const store = new Map()
|
||||
|
||||
export function cacheGet(key) {
|
||||
const entry = store.get(key)
|
||||
if (!entry) return null
|
||||
if (Date.now() > entry.expiresAt) {
|
||||
store.delete(key)
|
||||
return null
|
||||
}
|
||||
store.delete(key)
|
||||
store.set(key, entry)
|
||||
return entry.value
|
||||
}
|
||||
|
||||
export function cacheSet(key, value) {
|
||||
if (store.size >= MAX_ENTRIES) {
|
||||
const oldest = store.keys().next().value
|
||||
store.delete(oldest)
|
||||
}
|
||||
store.set(key, { value, expiresAt: Date.now() + TTL_MS })
|
||||
}
|
||||
Reference in New Issue
Block a user