{"id":24491432,"url":"https://github.com/patelvivekdev/libsql-kv","last_synced_at":"2026-02-14T10:05:01.031Z","repository":{"id":272097894,"uuid":"915535050","full_name":"patelvivekdev/libsql-kv","owner":"patelvivekdev","description":" A key-value store built on top of libSQL Turso","archived":false,"fork":false,"pushed_at":"2025-01-14T20:41:40.000Z","size":67,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T15:49:28.124Z","etag":null,"topics":["kv-store","libsql","serverless","turso"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/libsql-kv","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/patelvivekdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-12T05:17:18.000Z","updated_at":"2025-04-08T01:22:54.000Z","dependencies_parsed_at":"2025-01-12T05:20:11.865Z","dependency_job_id":"d12b28db-6da4-4fe0-935b-32964c9424bf","html_url":"https://github.com/patelvivekdev/libsql-kv","commit_stats":null,"previous_names":["patelvivekdev/libsql-kv"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/patelvivekdev/libsql-kv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patelvivekdev%2Flibsql-kv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patelvivekdev%2Flibsql-kv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patelvivekdev%2Flibsql-kv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patelvivekdev%2Flibsql-kv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patelvivekdev","download_url":"https://codeload.github.com/patelvivekdev/libsql-kv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patelvivekdev%2Flibsql-kv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29442335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["kv-store","libsql","serverless","turso"],"created_at":"2025-01-21T18:18:09.668Z","updated_at":"2026-02-14T10:04:56.021Z","avatar_url":"https://github.com/patelvivekdev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libsql-kv\n\nA flexible key-value store built on top of libSQL, providing an easy way to store, retrieve, and manage data with optional TTL (time-to-live) support.\n\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/packagelibsql-kv\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/libsql-kv\"/\u003e\u003ca\u003e\n\u003ca href=\"https://www.npmjs.com/package/libsql-kv\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/libsql-kv\"/\u003e\u003ca\u003e\n\u003ca href=\"https://github.com/patelvivekdev/libsql-kv/actions/workflows/CI.yml\"\u003e\u003cimg src=\"https://github.com/patelvivekdev/libsql-kv/actions/workflows/CI.yml/badge.svg\"/\u003e\u003ca\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\n\n## Installation\n\n```bash\nnpm install libsql-kv\n```\n\n```bash\nbun add libsql-kv\n```\n\n## Basic Usage\n\n```typescript\nimport { createKVStore } from 'libsql-kv';\n\nasync function example() {\n  const store = createKVStore({\n    url: 'file:./path/to/kv-store.db',\n    // ...other config like authToken or debug\n  });\n\n  // Initialize the KV store\n  await store.initialize();\n\n  // Set a value with optional TTL (in ms)\n  await store.set('myKey', { foo: 'bar' }, 60000);\n\n  // Get the value\n  const data = await store.get('myKey');\n  console.log(data); // { foo: 'bar' }\n\n  // Delete the value\n  await store.delete('myKey');\n\n  // Close the client connection\n  await store.close();\n}\n\nexample();\n```\n\n## Environment Variables\n\n- `LIBSQL_URL` (e.g., `libsql://your-database.turso.io` or `file:./kv-store.db`)\n- `LIBSQL_AUTH_TOKEN` (optional; required for remote databases)\n\nThe library uses these variables if no configuration is provided. Defaults to `file:./kv-store.db`.\n\n## Advanced Configuration\n\nYou can pass additional configuration properties when creating the KV store:\n\n```typescript\nconst store = createKVStore({\n  url: 'libsql://your-database.turso.io',\n  authToken: 'my-secret-token',\n  debug: true,\n  allowStale: false, // Control whether to allow reading expired data\n});\n```\n\n## API\n\n### `initialize()`\n\nCreates the underlying table if it doesn’t exist. Must be called before using any other methods.\n\n### `set(key, value, ttl?)`\n\nStores a value with an optional time-to-live in milliseconds. Overwrites existing data under the same key.\n\n### `get(key, allowStale?)`\n\nRetrieves the stored value. If the data has expired:\n\n- Returns null by default\n- Returns the expired data if `allowStale` is true\n- The `allowStale` parameter overrides the store-level setting\n\nExample:\n\n```typescript\n// Get with default stale behavior\nconst data1 = await store.get('myKey');\n\n// Override to allow stale data for this specific call\nconst data2 = await store.get('myKey', true);\n```\n\n### `delete(key)`\n\nRemoves a specific key-value entry from the store.\n\n### `clearExpired()`\n\nRemoves all entries whose TTL has expired. Returns the number of entries removed.\n\n### `close()`\n\nGracefully closes the underlying client/connection to libSQL.\n\n### `isInitialized()`\n\nChecks if the KV store has already been initialized.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatelvivekdev%2Flibsql-kv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatelvivekdev%2Flibsql-kv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatelvivekdev%2Flibsql-kv/lists"}