File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { mainDb } from './connection.js' ;
22import { sql } from 'kysely' ;
33import { redisConnection } from './connection.js' ;
4+ import { UPDATE_MODAL_REDIS_SEC } from '../utils/cacheTtl.js' ;
45
56const ACTIVE_MODAL_CACHE_KEY = 'update_modal:active' ;
67
@@ -28,7 +29,7 @@ export async function getActiveUpdateModal() {
2829 ACTIVE_MODAL_CACHE_KEY ,
2930 JSON . stringify ( result ) ,
3031 'EX' ,
31- 24 * 60 * 60
32+ UPDATE_MODAL_REDIS_SEC
3233 ) ;
3334 } catch ( error ) {
3435 console . warn ( '[Redis] Failed to cache active modal:' , error ) ;
Original file line number Diff line number Diff line change 11import { mainDb } from './connection.js' ;
2+ import { APP_VERSION_REDIS_SEC } from '../utils/cacheTtl.js' ;
23
34export async function getAppVersion ( ) {
45 const result = await mainDb
@@ -27,7 +28,12 @@ export async function getAppVersion() {
2728
2829 try {
2930 const { redisConnection } = await import ( './connection.js' ) ;
30- await redisConnection . set ( 'app:version' , JSON . stringify ( defaultVersion ) ) ;
31+ await redisConnection . set (
32+ 'app:version' ,
33+ JSON . stringify ( defaultVersion ) ,
34+ 'EX' ,
35+ APP_VERSION_REDIS_SEC
36+ ) ;
3137 } catch ( error ) {
3238 console . warn ( '[Redis] Failed to set version cache:' , error ) ;
3339 }
@@ -42,7 +48,12 @@ export async function getAppVersion() {
4248
4349 try {
4450 const { redisConnection } = await import ( './connection.js' ) ;
45- await redisConnection . set ( 'app:version' , JSON . stringify ( versionData ) ) ;
51+ await redisConnection . set (
52+ 'app:version' ,
53+ JSON . stringify ( versionData ) ,
54+ 'EX' ,
55+ APP_VERSION_REDIS_SEC
56+ ) ;
4657 } catch ( error ) {
4758 console . warn ( '[Redis] Failed to set version cache:' , error ) ;
4859 }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { requirePermission } from '../../middleware/rolePermissions.js';
55import { getDailyStatistics , getTotalStatistics } from '../../db/admin.js' ;
66import { getAppVersion , updateAppVersion } from '../../db/version.js' ;
77import { redisConnection } from '../../db/connection.js' ;
8+ import { APP_VERSION_REDIS_SEC } from '../../utils/cacheTtl.js' ;
89
910import usersRouter from './users.js' ;
1011import sessionsRouter from './sessions.js' ;
@@ -107,7 +108,7 @@ router.put(
107108 cacheKey ,
108109 JSON . stringify ( updatedVersion ) ,
109110 'EX' ,
110- 86400
111+ APP_VERSION_REDIS_SEC
111112 ) ;
112113 } catch ( error ) {
113114 if ( error instanceof Error ) {
You can’t perform that action at this time.
0 commit comments