use CacheRequest instead of key

This commit is contained in:
Muki Kiboigo
2026-03-26 16:20:38 -07:00
parent 368ac00573
commit def6e564d2
3 changed files with 15 additions and 10 deletions

View File

@@ -19,6 +19,7 @@
const std = @import("std");
const Cache = @import("Cache.zig");
const Http = @import("../http.zig");
const CacheRequest = Cache.CacheRequest;
const CachedMetadata = Cache.CachedMetadata;
const CachedResponse = Cache.CachedResponse;
@@ -96,8 +97,8 @@ pub fn cache(self: *FsCache) Cache {
return Cache.init(self);
}
pub fn get(self: *FsCache, arena: std.mem.Allocator, key: []const u8) ?Cache.CachedResponse {
const hashed_key = hashKey(key);
pub fn get(self: *FsCache, arena: std.mem.Allocator, req: CacheRequest) ?Cache.CachedResponse {
const hashed_key = hashKey(req.url);
const meta_p = metaPath(&hashed_key);
const body_p = bodyPath(&hashed_key);
@@ -141,8 +142,8 @@ pub fn get(self: *FsCache, arena: std.mem.Allocator, key: []const u8) ?Cache.Cac
};
}
pub fn put(self: *FsCache, key: []const u8, meta: CachedMetadata, body: []const u8) !void {
const hashed_key = hashKey(key);
pub fn put(self: *FsCache, req: CacheRequest, meta: CachedMetadata, body: []const u8) !void {
const hashed_key = hashKey(req.url);
const meta_p = metaPath(&hashed_key);
const meta_tmp_p = metaTmpPath(&hashed_key);
const body_p = bodyPath(&hashed_key);