{"id":13686730,"url":"https://github.com/fibjs/fib-kv","last_synced_at":"2025-06-12T12:13:33.883Z","repository":{"id":57235122,"uuid":"84782312","full_name":"fibjs/fib-kv","owner":"fibjs","description":"general key-value store on sql/level/mongo/redis","archived":false,"fork":false,"pushed_at":"2025-04-18T19:50:39.000Z","size":52,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-01T22:25:18.367Z","etag":null,"topics":["key-value","store"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fibjs.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-03-13T03:58:19.000Z","updated_at":"2025-04-18T19:50:42.000Z","dependencies_parsed_at":"2025-05-01T09:32:47.813Z","dependency_job_id":null,"html_url":"https://github.com/fibjs/fib-kv","commit_stats":{"total_commits":37,"total_committers":4,"mean_commits":9.25,"dds":0.5135135135135135,"last_synced_commit":"38fc0c65a5776fb15eba774933fea50bcfd90c64"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/fibjs/fib-kv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-kv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-kv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-kv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-kv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibjs","download_url":"https://codeload.github.com/fibjs/fib-kv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-kv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259462578,"owners_count":22861514,"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":["key-value","store"],"created_at":"2024-08-02T15:00:38.918Z","updated_at":"2025-06-12T12:13:33.857Z","avatar_url":"https://github.com/fibjs.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["Database/Cache"],"readme":"# fib-kv\n\n[![NPM version](https://img.shields.io/npm/v/fib-kv.svg)](https://www.npmjs.org/package/fib-kv)\n[![Build Status](https://travis-ci.org/fibjs/fib-kv.svg)](https://travis-ci.org/fibjs/fib-kv)\n[![Build status](https://ci.appveyor.com/api/projects/status/they3hi2gq01vrev?svg=true)](https://ci.appveyor.com/project/richardo2016/fib-kv)\n\n## Introduction\n\ngeneral key-value store on sql/level/mongo/redis for fibjs.\n\n## Install\n\n```sh\nnpm install fib-kv [--save]\n```\n\n## Test\n\n```sh\nnpm run ci\n```\n\n## Creating a key-value store\n\n### var kvs = new kv(conn, opts);\n\n```JavaScript\nconn: database connection or connection factory like fib-pool\nopts: kvs options\n```\n\n| opts                 | default | object/Map | LruCache | LevelDB | Redis | MongoDB | SQLite/MySQL |\n|----------------------|---------|------------|----------|---------|-------|---------|--------------|\n| table_name           |   \"kvs\" | x          | x        | x       | √     | √       | √            |\n| key_name             |     \"k\" | x          | x        | x       | x     | √       | √            |\n| value_name           |     \"v\" | x          | x        | x       | x     | √       | √            |\n| key_size             |      32 | x          | x        | x       | x     | x       | √            |\n| value_size           |     256 | x          | x        | x       | x     | x       | √            |\n| cleanup_interval(ms) |   60000 | x          | x        | x       | x     | x       | √            |\n| timeout(ms)          |       0 | x          | √        | x       | √     | √       | √            |\n| prefix               |      \"\" | √          | √        | √       | √     | √       | √            |\n| cache                |   false | √          | √        | √       | √     | √       | √            |\n| cache_size           |   65536 | √          | √        | √       | √     | √       | √            |\n| cache_timeout(ms)    |   60000 | √          | √        | √       | √     | √       | √            |\n| sql_value_type       |   60000 | x          | x        | x       | x     | x       | √            |\n\n**NOTICE** sql_value_type is one of below:\n- TINYBLOB\n- BLOB\n- MEDIUMBLOB\n- LONGBLOB\n- TINYTEXT\n- TEXT\n- MEDIUMTEXT\n- LONGTEXT\n- VARCHAR\n\nA key will not expire if `timeout` is less than or equal to 0.\n\n#### Simple example (memory backend).\n```JavaScript\nvar kv = require(\"fib-kv\");\n\nvar kvs = new kv({\n    \"a\": 100,\n    \"b\": 200\n});\n```\n\n#### LevelDB backend.\n```JavaScript\nvar kv = require(\"fib-kv\");\nvar db = require(\"db\");\n\nvar kvs = new kv(db.openLevelDB(\"test.ldb\"));\n```\n\n#### fib-pool backend.\n```JavaScript\nvar kv = require(\"fib-kv\");\nvar db = require(\"db\");\nvar pool = require(\"fib-pool\");\n\nvar kvs = new kv(pool(() =\u003e db.openLevelDB(\"test.ldb\")));\n```\n\n## Methods\n\n### kvs.setup()\nsetup the backend database.\n\n### v = kvs.get(k)\nreturns the value stored for that key.\n\n### kvs.set(k, v)\nstores a key-value pair.\n\n### e = kvs.has(k)\nreturns whether a key is set on the store.\n\n### e = kvs.keys()\nreturns all keys in the store.\n\n### e = kvs.renew(k)\nrenews TTL for an unexpired key.\n\n### kvs.remove(k)\ndeletes a key-value pair by key.\n\n### e = kvs.cache_has(k)\nreturns whether a key is set on the cache.\n\n### kvs.cache_clear()\nremoves all the key-value pairs in the cache.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Ffib-kv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibjs%2Ffib-kv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Ffib-kv/lists"}