{"id":13448565,"url":"https://github.com/zaaack/keyv-file","last_synced_at":"2025-04-09T12:05:57.929Z","repository":{"id":48523366,"uuid":"99292956","full_name":"zaaack/keyv-file","owner":"zaaack","description":"File storage adapter for Keyv, using json to serialize data.","archived":false,"fork":false,"pushed_at":"2024-02-22T00:32:40.000Z","size":111,"stargazers_count":66,"open_issues_count":11,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-23T21:28:23.545Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zaaack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-08-04T02:09:28.000Z","updated_at":"2024-03-16T18:12:40.000Z","dependencies_parsed_at":"2024-02-22T01:44:39.481Z","dependency_job_id":null,"html_url":"https://github.com/zaaack/keyv-file","commit_stats":{"total_commits":39,"total_committers":6,"mean_commits":6.5,"dds":0.1282051282051282,"last_synced_commit":"52502077c78226b3d69a615c80b88e53be096979"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fkeyv-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fkeyv-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fkeyv-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fkeyv-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaaack","download_url":"https://codeload.github.com/zaaack/keyv-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036063,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:49.190Z","updated_at":"2025-04-09T12:05:57.897Z","avatar_url":"https://github.com/zaaack.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","others"],"sub_categories":[],"readme":"# keyv-file [\u003cimg width=\"100\" align=\"right\" src=\"https://rawgit.com/lukechilds/keyv/master/media/logo.svg\" alt=\"keyv\"\u003e](https://github.com/lukechilds/keyv)\n\n\u003e File storage adapter for Keyv, using json to serialize data fast and small.\n\n[![Build Status](https://travis-ci.org/zaaack/keyv-file.svg?branch=master)](https://travis-ci.org/zaaack/keyv-file)\n[![npm](https://img.shields.io/npm/v/keyv-file.svg)](https://www.npmjs.com/package/keyv-file)\n\nFile storage adapter for [Keyv](https://github.com/lukechilds/keyv).\n\nTTL functionality is handled internally by interval scan, don't need to panic about expired data take too much space.\n\n## Install\n\n```shell\nnpm install --save keyv keyv-file\n```\n\n## Usage\n\n### Using with keyv\n```js\nconst Keyv = require('keyv')\nconst { KeyvFile } = require('keyv-file')\n\nconst keyv = new Keyv({\n  store: new KeyvFile()\n});\n// More options with default value:\nconst customKeyv = new Keyv({\n  store: new KeyvFile({\n    filename: `${os.tmpdir()}/keyv-file/default-rnd-${Math.random().toString(36).slice(2)}.json`, // the file path to store the data\n    expiredCheckDelay: 24 * 3600 * 1000, // ms, check and remove expired data in each ms\n    writeDelay: 100, // ms, batch write to disk in a specific duration, enhance write performance.\n    encode: JSON.stringify, // serialize function\n    decode: JSON.parse // deserialize function\n  })\n})\n```\n\n### Using directly\n\n```ts\nimport KeyvFile, { makeField } from 'keyv-file'\n\nclass Kv extends KeyvFile {\n  constructor() {\n    super({\n      filename: './db.json'\n    })\n  }\n  someField = makeField(this, 'field_key')\n}\n\nexport const kv = new Kv\n\nkv.someField.get(1) // empty return default value 1\nkv.someField.set(2) // set value 2\nkv.someField.get() // return saved value 2\nkv.someField.delete() // delete field\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaaack%2Fkeyv-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaaack%2Fkeyv-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaaack%2Fkeyv-file/lists"}