check age on fs cache get

This commit is contained in:
Muki Kiboigo committed 2026-04-03 07:23:29 -07:00
1 parent 609983da87
commit 9d62e58c9a
1 file changed
+8
+8
View File
@@ -131,6 +131,14 @@ pub fn get(self: *FsCache, arena: std.mem.Allocator, req: CacheRequest) ?Cache.C
return null;
}
const now = std.time.timestamp();
const age = (now - metadata.stored_at) + @as(i64, @intCast(metadata.age_at_store));
if (age < 0 or @as(u64, @intCast(age)) >= metadata.cache_control.max_age) {
self.dir.deleteFile(&meta_p) catch {};
self.dir.deleteFile(&body_p) catch {};
return null;
}
const body_file = self.dir.openFile(
&body_p,
.{ .mode = .read_only },