fix(template): redis-backed instances always show ttl 1 (#15536)

This commit is contained in:
Tony 2024-05-10 03:47:21 +08:00 committed by GitHub
parent 1de0c62bdf
commit b0b7adf382
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -4,14 +4,14 @@ import { collapseWhitespace, convertDateToISO8601 } from '@/utils/common-utils';
import type { MiddlewareHandler } from 'hono';
import { Data } from '@/types';
// Set RSS <ttl> (minute) according to the availability of cache
// * available: max(config.cache.routeExpire / 60, 1)
// * unavailable: 1
// The minimum <ttl> is limited to 1 minute to prevent potential misuse
import cacheModule from '@/utils/cache/index';
const ttl = (cacheModule.status.available && Math.trunc(config.cache.routeExpire / 60)) || 1;
const middleware: MiddlewareHandler = async (ctx, next) => {
// Set RSS <ttl> (minute) according to the availability of cache
// * available: max(config.cache.routeExpire / 60, 1)
// * unavailable: 1
// The minimum <ttl> is limited to 1 minute to prevent potential misuse
const ttl = (cacheModule.status.available && Math.trunc(config.cache.routeExpire / 60)) || 1;
await next();
const data: Data = ctx.get('data');