- Notifications
You must be signed in to change notification settings - Fork11
File storage adapter for Keyv, using json to serialize data.
License
NotificationsYou must be signed in to change notification settings
zaaack/keyv-file
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
File storage adapter for Keyv, using json to serialize data fast and small.
File storage adapter forKeyv.
TTL functionality is handled internally by interval scan, don't need to panic about expired data take too much space.
npm install --save keyv keyv-file
npx skills add https://github.com/zaaack/prompts --skill keyv-file
constKeyv=require('keyv')const{ KeyvFile}=require('keyv-file')constkeyv=newKeyv({store:newKeyvFile()});// More options with default value:constcustomKeyv=newKeyv({store:newKeyvFile({filename:`${os.tmpdir()}/keyv-file/default.json`,// the file path to store the dataexpiredCheckDelay:24*3600*1000,// ms, check and remove expired data in each mswriteDelay:100,// ms, batch write to disk in a specific duration, enhance write performance.encode:JSON.stringify,// serialize functiondecode:JSON.parse// deserialize function})})
importKeyvFile,{makeField}from'keyv-file'classKvextendsKeyvFile{constructor(){super({filename:'./db.json'})}someField=makeField(this,'field_key')}exportconstkv=newKvkv.someField.get(1)// empty return default value 1kv.someField.set(2)// set value 2kv.someField.get()// return saved value 2kv.someField.delete()// delete field
MIT
About
File storage adapter for Keyv, using json to serialize data.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.