File storage adapter for Keyv, using JSON (or msgpack) to serialize data fast and small. Current stable version is 5.3.3, with regular releases. It provides persistent caching with efficient TTL handling via interval scans, batch write delays for performance, and direct usage patterns with field-based access. Compared to other Keyv storage adapters, keyv-file focuses on simplicity and local file persistence, making it suitable for small-scale caching needs where a database is overkill.
npm install keyv-fileNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes Keyv with a file store, sets and gets a value, demonstrating basic caching.
Use import syntax instead of require().
Switch to JSON default or explicitly set encode/decode.
Use await keyv.set() and ensure write delay elapses or flush manually.
Set expiredCheckDelay lower for more frequent cleanup, or accept eventual cleanup.
Use { KeyvFile } instead of KeyvFile as default import.Switch to import { KeyvFile } from 'keyv-file'.Run npm install keyv.
Ensure you do new KeyvFile({...}) and import correctly.Ensure the file content is valid JSON.