Null Cache Driver
Disables caching entirely. Useful for testing, debugging, or temporarily turning off cache without code changes.
When to Use
Section titled “When to Use”- Testing environments
- Debugging cache-related issues
- Measuring performance impact of caching
Configuration
Section titled “Configuration”import { NullCacheDriver } from "@warlock.js/cache";
const cacheConfigurations = { default: "null", drivers: { null: NullCacheDriver, }, options: { null: {}, },};Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
* | any | undefined | All options are accepted but ignored |
Behavior
Section titled “Behavior”All cache operations succeed but store nothing:
set(): Returns the value without storingget(): Always returnsnullremove(): Always succeedsflush(): Always succeeds
Example Usage
Section titled “Example Usage”import { cache } from "@warlock.js/cache";
await cache.set("products.101", data, 3600); // Returns data without storingconst result = await cache.get("products.101"); // Returns nullawait cache.remove("products.101"); // Succeedsawait cache.flush(); // Succeedsn/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.