{"id":26544069,"url":"https://github.com/lucasvmiguel/kv-store","last_synced_at":"2025-03-22T03:17:15.439Z","repository":{"id":52490500,"uuid":"182061045","full_name":"lucasvmiguel/kv-store","owner":"lucasvmiguel","description":"Key value store library that uses your current database (for you that don't want to spend even more money)","archived":false,"fork":false,"pushed_at":"2022-12-30T18:23:09.000Z","size":176,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-18T04:42:52.020Z","etag":null,"topics":["keyvalue","mysql","nodejs","redis","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lucasvmiguel.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}},"created_at":"2019-04-18T09:44:43.000Z","updated_at":"2019-08-08T14:50:11.000Z","dependencies_parsed_at":"2023-01-31T13:00:23.630Z","dependency_job_id":null,"html_url":"https://github.com/lucasvmiguel/kv-store","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasvmiguel%2Fkv-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasvmiguel%2Fkv-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasvmiguel%2Fkv-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasvmiguel%2Fkv-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucasvmiguel","download_url":"https://codeload.github.com/lucasvmiguel/kv-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244898427,"owners_count":20528342,"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":["keyvalue","mysql","nodejs","redis","typescript"],"created_at":"2025-03-22T03:17:14.560Z","updated_at":"2025-03-22T03:17:15.419Z","avatar_url":"https://github.com/lucasvmiguel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"logo/horizontal.png\" alt=\"kv-store\" height=\"80px\"\u003e\u003c/p\u003e\n\n[![Version](https://img.shields.io/npm/v/@lucasvmiguel/kv-store.svg)](https://www.npmjs.org/package/@lucasvmiguel/kv-store)\n[![Build Status](https://travis-ci.org/lucasvmiguel/kv-store.svg?branch=master)](https://travis-ci.org/lucasvmiguel/kv-store)\n[![Downloads](https://img.shields.io/npm/dm/@lucasvmiguel/kv-store.svg)](https://www.npmjs.org/package/@lucasvmiguel/kv-store)\n\n## Description\nKey value store library that uses a few database options. It might be the case that you don't want to spend money in a new instance or in another service.\n\nAdapters available:\n* Local\n* MySQL\n* Redis\n* Postgres (roadmap)\n* MongoDB (roadmap)\n\n## Installation\n\n```bash\nnpm install --save @lucasvmiguel/kv-store\n```\n\n## How to use\n\n#### MySQL\n```js\nimport * as kvStore from '@lucasvmiguel/kv-store';\n\nconst connection = mysql.createConnection({\n    host: '...',\n    user: '...',\n    password: '...',\n    port: '...',\n    database: '...',\n});\n\nawait kvStore.init({\n  type: 'mysql',\n  client: connection,\n  tableName: 'kvstore_keyvalues', // OPTIONAL\n  debug: false, // OPTIONAL\n});\n\nawait kvStore.put('USER:123', 'abc');\nconst abc = await kvStore.get('USER:123');\n\n// Expiration in seconds\nawait kvStore.putJson('USER:456', {foo: \"bar\"}, { expiration: 60 });\nconst fooBar = await kvStore.getJson('USER:456');\n```\n\n#### Redis\n```js\nimport * as kvStore from '@lucasvmiguel/kv-store';\n\nconst connection = redis.createClient(6379, '127.0.0.1')\n\nawait kvStore.init({\n  type: 'redis',\n  client: connection,\n  tableName: 'kvstore_keyvalues', // OPTIONAL\n  debug: false, // OPTIONAL\n});\n\nawait kvStore.put('USER:123', 'abc');\nconst abc = await kvStore.get('USER:123');\n\n// Expiration in seconds\nawait kvStore.putJson('USER:456', {foo: \"bar\"}, { expiration: 60 });\nconst fooBar = await kvStore.getJson('USER:456');\n```\n\n#### Local\n```js\nimport * as kvStore from '@lucasvmiguel/kv-store';\n\nawait kvStore.init({\n  type: 'local',\n  client: null,\n  tableName: 'kvstore_keyvalues', // OPTIONAL\n  debug: false, // OPTIONAL\n});\n\nawait kvStore.put('USER:123', 'abc');\nconst abc = await kvStore.get('USER:123');\n\n// Expiration in seconds\nawait kvStore.putJson('USER:456', {foo: \"bar\"}, { expiration: 60 });\nconst fooBar = await kvStore.getJson('USER:456');\n```\n\n## API Reference\n\n* expiration is in seconds\n* just pass null to init if is local cache\n\n```typescript\nfunction init: ({\n    type: 'mysql' OR 'redis' OR 'local',\n    client: mysql.Connection OR redis.RedisClient OR null,\n    tableName?: string;\n    debug?: boolean;\n}) =\u003e Promise\u003cboolean\u003e\n```\n\n```js\nfunction refresh(connection: mysql.Connection OR redis.RedisClient OR null) =\u003e Promise\u003cboolean\u003e\n```\n\n```js\nfunction get(key: string) =\u003e Promise\u003cstring OR null\u003e;\n```\n\n```js\nfunction put(key: string, value: string, options?: {expiration?: number}) =\u003e Promise\u003cboolean\u003e\n```\n\n```js\nfunction del(key: string) =\u003e Promise\u003cboolean OR null\u003e\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucasvmiguel%2Fkv-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucasvmiguel%2Fkv-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucasvmiguel%2Fkv-store/lists"}