Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place

add cache-only mode to skip DB writes

+11 -1
+3 -1
apps/hosting-service/src/index.ts
··· 2 2 import { serve } from '@hono/node-server'; 3 3 import { initializeGrafanaExporters, createLogger } from '@wispplace/observability'; 4 4 import { mkdirSync, existsSync } from 'fs'; 5 - import { startDomainCacheCleanup, stopDomainCacheCleanup, closeDatabase } from './lib/db'; 5 + import { startDomainCacheCleanup, stopDomainCacheCleanup, closeDatabase, CACHE_ONLY } from './lib/db'; 6 6 import { closeRevalidateQueue } from './lib/revalidate-queue'; 7 7 import { startCacheInvalidationSubscriber, stopCacheInvalidationSubscriber } from './lib/cache-invalidation'; 8 8 import { storage, getStorageConfig } from './lib/storage'; ··· 69 69 70 70 Server: http://localhost:${PORT} 71 71 Health: http://localhost:${PORT}/health 72 + 73 + Mode: ${CACHE_ONLY ? 'CACHE-ONLY (no DB writes)' : 'Standard (with DB writes)'} 72 74 73 75 Tiered Storage Configuration: 74 76 Hot Cache: ${storageConfig.hotCacheSize} (${storageConfig.hotCacheCount} items max)
+8
apps/hosting-service/src/lib/db.ts
··· 10 10 } 11 11 ); 12 12 13 + // Cache-only mode: skip all DB writes and only use tiered storage 14 + export const CACHE_ONLY = process.env.CACHE_ONLY === 'true'; 15 + 13 16 // Domain lookup cache with TTL 14 17 const DOMAIN_CACHE_TTL = 5 * 60 * 1000; // 5 minutes 15 18 ··· 128 131 recordCid: string, 129 132 fileCids: Record<string, string> 130 133 ): Promise<void> { 134 + if (CACHE_ONLY) { 135 + console.log('[DB] Cache-only mode: skipping upsertSiteCache', { did, rkey }); 136 + return; 137 + } 138 + 131 139 try { 132 140 await sql` 133 141 INSERT INTO site_cache (did, rkey, record_cid, file_cids, cached_at, updated_at)