add
Add a texture to the cache. This is useful if you want to load
and image from disk, create a texture from it and then unload
it from memory. The texture will remain in the cache as long
as it's key is accessed at least once per call to reset.
Parameters
Source
Implementation
pub fn add(self: *Cache, gpa: std.mem.Allocator, key: Key, texture: Texture) std.mem.Allocator.Error!void {
try self.trash.ensureUnusedCapacity(gpa, 1);
const prev = try self.cache.fetchPut(gpa, key, texture);
if (prev) |kv| {
self.trash.appendAssumeCapacity(kv.value);
}
}