fix: persist topic session files
This commit is contained in:
1 parent
67d1f61872
commit
b2de667b11
6 files changed
+84
-37
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import fs from "node:fs";
|
||||
|
||||
export function resolveCacheTtlMs(params: {
|
||||
envValue: string | undefined;
|
||||
defaultTtlMs: number;
|
||||
}): number {
|
||||
const { envValue, defaultTtlMs } = params;
|
||||
if (envValue) {
|
||||
const parsed = Number.parseInt(envValue, 10);
|
||||
if (Number.isFinite(parsed) && parsed >= 0) {
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
return defaultTtlMs;
|
||||
}
|
||||
|
||||
export function isCacheEnabled(ttlMs: number): boolean {
|
||||
return ttlMs > 0;
|
||||
}
|
||||
|
||||
export function getFileMtimeMs(filePath: string): number | undefined {
|
||||
try {
|
||||
return fs.statSync(filePath).mtimeMs;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user