a cache for slack profile pictures and emojis

feat: add sqlite options for even faster performance

dunkirk.sh 3afe53b0 7f931006

verified
+26
+26
src/cache.ts
··· 372 372 this.defaultExpiration = defaultExpirationHours; 373 373 this.onEmojiExpired = onEmojiExpired; 374 374 375 + // Optimize SQLite for performance 376 + this.optimizeSQLite(); 377 + 375 378 // Initialize type-safe analytics cache 376 379 this.typedAnalyticsCache = new AnalyticsCache(); 377 380 ··· 382 385 383 386 // Run migrations 384 387 this.runMigrations(); 388 + } 389 + 390 + /** 391 + * Optimizes SQLite performance settings 392 + * @private 393 + */ 394 + private optimizeSQLite() { 395 + // Enable Write-Ahead Logging for better concurrency 396 + this.db.run("PRAGMA journal_mode = WAL"); 397 + 398 + // NORMAL synchronous mode is faster and still safe with WAL 399 + this.db.run("PRAGMA synchronous = NORMAL"); 400 + 401 + // Increase cache size to 64MB for better query performance 402 + this.db.run("PRAGMA cache_size = -64000"); 403 + 404 + // Store temporary tables in memory 405 + this.db.run("PRAGMA temp_store = MEMORY"); 406 + 407 + // Enable memory-mapped I/O for faster reads (256MB) 408 + this.db.run("PRAGMA mmap_size = 268435456"); 409 + 410 + console.log("SQLite performance optimizations applied"); 385 411 } 386 412 387 413 /**