From 5213287f3880166eccc6e443bf12c50fc8323a55 Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Thu, 19 Mar 2026 18:50:05 -0700 Subject: [PATCH] create cache owned by the network struct --- src/network/Runtime.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/network/Runtime.zig b/src/network/Runtime.zig index 72aebe81..fd4cefda 100644 --- a/src/network/Runtime.zig +++ b/src/network/Runtime.zig @@ -29,6 +29,7 @@ const libcurl = @import("../sys/libcurl.zig"); const net_http = @import("http.zig"); const RobotStore = @import("Robots.zig").RobotStore; const WebBotAuth = @import("WebBotAuth.zig"); +const Cache = @import("cache/Cache.zig"); const Runtime = @This(); @@ -49,6 +50,7 @@ config: *const Config, ca_blob: ?net_http.Blob, robot_store: RobotStore, web_bot_auth: ?WebBotAuth, +cache: ?Cache, connections: []net_http.Connection, available: std.DoublyLinkedList = .{}, @@ -233,6 +235,11 @@ pub fn init(allocator: Allocator, config: *const Config) !Runtime { else null; + const cache = if (config.cacheDir()) |cache_dir_path| + Cache{ .kind = .{ .fs = try .init(cache_dir_path) } } + else + null; + return .{ .allocator = allocator, .config = config, @@ -246,6 +253,7 @@ pub fn init(allocator: Allocator, config: *const Config) !Runtime { .robot_store = RobotStore.init(allocator), .web_bot_auth = web_bot_auth, + .cache = cache, }; }