Loading...
Loading...
Specialized in the `keyv-file` adapter for Keyv. Use this when the user needs persistent file-based storage with features like batch writing (writeDelay), TTL management (expiredCheckDelay), and the `makeField` API for direct access.
npx skill4agent add zaaack/prompts keyv-fileKeyvFile| Option | Default Value | Description |
|---|---|---|
| | The path where your data is persisted. |
| | Interval (ms) to scan and purge expired keys from the file. |
| | Delay (ms) to batch multiple write operations, reducing disk I/O. |
| | Custom serialization function. |
| | Custom deserialization function. |
const Keyv = require('keyv')
const { KeyvFile } = require('keyv-file')
const keyv = new Keyv({
store: new KeyvFile({
filename: './data/cache.json',
writeDelay: 50 // Faster writes for high-frequency updates
})
});
KeyvFilemakeFieldimport KeyvFile, { makeField } from 'keyv-file'
class MyDatabase extends KeyvFile {
constructor() {
super({ filename: './db.json' })
}
// Creates a dedicated helper for a specific key
userSettings = makeField(this, 'user_settings_key')
}
const db = new MyDatabase()
await db.userSettings.set({ theme: 'dark' })
const settings = await db.userSettings.get({ theme: 'light' }) // returns default if empty