{"id":21975106,"url":"https://github.com/nwaughachukwuma/keyv-cache","last_synced_at":"2025-04-28T15:43:54.634Z","repository":{"id":64580623,"uuid":"576010226","full_name":"nwaughachukwuma/keyv-cache","owner":"nwaughachukwuma","description":"simple key/value wrapper (with TTL) for the browser cache-api with zero dependencies.","archived":false,"fork":false,"pushed_at":"2023-11-27T01:31:21.000Z","size":226,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T16:03:56.774Z","etag":null,"topics":["cache-api","cache-api-wrapper","cache-with-ttl","key-value-store"],"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/nwaughachukwuma.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,"publiccode":null,"codemeta":null}},"created_at":"2022-12-08T19:59:56.000Z","updated_at":"2025-02-14T21:19:59.000Z","dependencies_parsed_at":"2024-11-29T15:49:57.800Z","dependency_job_id":"d93eaeba-83bb-438e-828c-880547afefc0","html_url":"https://github.com/nwaughachukwuma/keyv-cache","commit_stats":{"total_commits":85,"total_committers":1,"mean_commits":85.0,"dds":0.0,"last_synced_commit":"66de5d3ff4103dab455a0a683374469b81a79e29"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwaughachukwuma%2Fkeyv-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwaughachukwuma%2Fkeyv-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwaughachukwuma%2Fkeyv-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwaughachukwuma%2Fkeyv-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nwaughachukwuma","download_url":"https://codeload.github.com/nwaughachukwuma/keyv-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251341164,"owners_count":21574071,"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":["cache-api","cache-api-wrapper","cache-with-ttl","key-value-store"],"created_at":"2024-11-29T15:49:50.937Z","updated_at":"2025-04-28T15:43:54.579Z","avatar_url":"https://github.com/nwaughachukwuma.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keyv-cache 🚀\n\nA tiny `key/value` wrapper for the browser [Cache API](https://developer.mozilla.org/en-US/docs/Web/API/Cache) with zero dependencies. It provides a simple key-value interface with Time to Live (TTL) support.\n\n## Key Features\n\n- ✅ Less than 1kB - lightweight with zero dependencies\n- 🚀 Super easy to use - intuitive API\n- 🔒 Namespacing - isolate caches by namespace for your app\n- 📦 Flexible values - cache any serializable value\n\n## Installation\n\n```bash\n\nnpm install keyv-cache\n\n```\n\n## 📖 Usage\n\n```js\nimport KeyvCache from \"keyv-cache\";\nconst cache = KeyvCache({ namespace: \"my-app\" });\n\n// within an async function\nconst ONE_HOUR = 60 * 60 * 1000;\nawait cache.set(\"foo\", \"bar\", ONE_HOUR);\n\n// somewhere/sometime later\nconst value = await cache.get(\"foo\");\n```\n\n## API\n\nTo create a new KeyvCache instance:\n\n```js\nKeyvCache(options);\n```\n\n### options: { namespace: string }\n\nAn object that can contain the following options:\n\n- **namespace**: The namespace for isolating caches\n\n### cache methods\n\nThe object returned for a namespace has the following methods:\n\n1. `set(key: string, value: any, ttl: number) =\u003e Promise\u003cvoid\u003e`\n\n   - Set a key-value pair with a TTL in ms\n   - **value**: any serializable primitive or object.\n\n2. `get(key: string) =\u003e Promise\u003cany\u003e`\n\n   - Get the value for a key; Returns `null` if the key does not exist, or is expired.\n\n3. `has(key: string) =\u003e Promise\u003cboolean\u003e`\n\n   - Check if a key exists.\n\n4. `remove(key: string) =\u003e Promise\u003cvoid\u003e`\n\n   - Remove a key from the cache.\n\n5. `removePattern(pattern: string) =\u003e Promise\u003cvoid\u003e`\n\n   - Removes all keys from a cache namespace matching the pattern. Support for regex patterns is coming soon.\n\n6. `keys() =\u003e Promise\u003cstring[]\u003e`\n\n   - Returns an array of all keys in a cache namespace.\n\n7. `clear() =\u003e Promise\u003cvoid\u003e`\n\n   - Removes all keys from a cache namespace.\n\n## ⚡ Performance\n\nKeyv-cache uses the built-in and super fast Browser Cache API under the hood. This makes it ideal for caching data on the client-side without sacrificing performance.\nThe fallback memory cache is also very fast for environments where the Browser Cache API is not supported.\n\n## 🏆 Contributing\n\nWe welcome contributions big and small! Please feel welcomed to send a PR or open an issue.\n\nMIT © Chukwuma Nwaugha\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwaughachukwuma%2Fkeyv-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnwaughachukwuma%2Fkeyv-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwaughachukwuma%2Fkeyv-cache/lists"}