From e3cd9af6dffc0901730bd10f3d8c57361cf8e775 Mon Sep 17 00:00:00 2001 From: Hemachandar <132386067+hmacr@users.noreply.github.com> Date: Sat, 24 Aug 2024 18:06:12 +0530 Subject: [PATCH] fix: Set redis expiry in seconds (#7456) * fix: Set redis expiry in seconds * change expiry for github and iframely --- plugins/github/server/index.ts | 2 +- plugins/iframely/server/index.ts | 2 +- server/utils/CacheHelper.ts | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/github/server/index.ts b/plugins/github/server/index.ts index 501ec91819..6015ed2fcb 100644 --- a/plugins/github/server/index.ts +++ b/plugins/github/server/index.ts @@ -22,7 +22,7 @@ if (enabled) { }, { type: Hook.UnfurlProvider, - value: { unfurl: GitHub.unfurl, cacheExpiry: Minute }, + value: { unfurl: GitHub.unfurl, cacheExpiry: Minute / 1000 }, }, { type: Hook.Uninstall, diff --git a/plugins/iframely/server/index.ts b/plugins/iframely/server/index.ts index e3dd50af89..1e1f6ffd9c 100644 --- a/plugins/iframely/server/index.ts +++ b/plugins/iframely/server/index.ts @@ -19,7 +19,7 @@ if (enabled) { PluginManager.add([ { type: Hook.UnfurlProvider, - value: { unfurl: Iframely.unfurl, cacheExpiry: Day }, + value: { unfurl: Iframely.unfurl, cacheExpiry: Day / 1000 }, // Make sure this is last in the stack to be evaluated after all other unfurl providers priority: PluginPriority.VeryLow, diff --git a/server/utils/CacheHelper.ts b/server/utils/CacheHelper.ts index a2eb8bb1ea..b53728bdf1 100644 --- a/server/utils/CacheHelper.ts +++ b/server/utils/CacheHelper.ts @@ -6,8 +6,8 @@ import Redis from "@server/storage/redis"; * A Helper class for server-side cache management */ export class CacheHelper { - // Default expiry time for cache data in ms - private static defaultDataExpiry = Day; + // Default expiry time for cache data in seconds + private static defaultDataExpiry = Day / 1000; /** * Given a key, gets the data from cache store @@ -32,7 +32,7 @@ export class CacheHelper { * * @param key Cache key * @param data Data to be saved against the key - * @param expiry Cache data expiry + * @param expiry Cache data expiry in seconds */ public static async setData(key: string, data: T, expiry?: number) { try {