Skip to content
Warlock.js v4

Null Cache Driver

Disables caching entirely. Useful for testing, debugging, or temporarily turning off cache without code changes.

  • Testing environments
  • Debugging cache-related issues
  • Measuring performance impact of caching
src/config/cache.ts
import { NullCacheDriver } from "@warlock.js/cache";
const cacheConfigurations = {
default: "null",
drivers: {
null: NullCacheDriver,
},
options: {
null: {},
},
};
OptionTypeDefaultDescription
*anyundefinedAll options are accepted but ignored

All cache operations succeed but store nothing:

  • set(): Returns the value without storing
  • get(): Always returns null
  • remove(): Always succeeds
  • flush(): Always succeeds
import { cache } from "@warlock.js/cache";
await cache.set("products.101", data, 3600); // Returns data without storing
const result = await cache.get("products.101"); // Returns null
await cache.remove("products.101"); // Succeeds
await cache.flush(); // Succeeds

n/a — cache.similar(...) returns [] (matches the driver’s read semantics) and set({ vector }) is a no-op like every other write. The null driver is for tests and benchmarks.