Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

File storage adapter for Keyv, using json to serialize data.

License

NotificationsYou must be signed in to change notification settings

zaaack/keyv-file

Repository files navigation

File storage adapter for Keyv, using json to serialize data fast and small.

publishnpm

File storage adapter forKeyv.

TTL functionality is handled internally by interval scan, don't need to panic about expired data take too much space.

Install

npm install --save keyv keyv-file

Usage

Using with AI agent

npx skills add https://github.com/zaaack/prompts --skill keyv-file

Using with keyv

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})})

Using directly

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

License

MIT

About

File storage adapter for Keyv, using json to serialize data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors8


[8]ページ先頭

©2009-2026 Movatter.jp