{"id":24452906,"url":"https://github.com/extensionengine/tapster","last_synced_at":"2026-04-17T10:32:39.922Z","repository":{"id":41109974,"uuid":"353754855","full_name":"ExtensionEngine/tapster","owner":"ExtensionEngine","description":"Cache adapter module for NodeJs.","archived":false,"fork":false,"pushed_at":"2023-03-07T16:42:43.000Z","size":1407,"stargazers_count":2,"open_issues_count":10,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-06T02:07:46.008Z","etag":null,"topics":[],"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/ExtensionEngine.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":"2021-04-01T16:04:27.000Z","updated_at":"2022-03-17T17:04:06.000Z","dependencies_parsed_at":"2023-02-08T06:15:17.562Z","dependency_job_id":null,"html_url":"https://github.com/ExtensionEngine/tapster","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExtensionEngine%2Ftapster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExtensionEngine%2Ftapster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExtensionEngine%2Ftapster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExtensionEngine%2Ftapster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExtensionEngine","download_url":"https://codeload.github.com/ExtensionEngine/tapster/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243534278,"owners_count":20306488,"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":"2025-01-21T01:17:34.596Z","updated_at":"2025-12-30T15:58:23.078Z","avatar_url":"https://github.com/ExtensionEngine.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tapster\nCache adapter module for NodeJs.\n\n## Installation:\n```\nnpm install @extensionengine/tapster\n```\n```js\nconst { CacheManager } = require('@extensionengine/tapster');\nconst cache = new CacheManager({ /* ... */ });\n```\n\n## Store providers\n- `memory` (uses [LRU](https://github.com/isaacs/node-lru-cache))\n- `redis` (uses [ioredis](https://github.com/luin/ioredis))\n- custom - use any store you want, as long as it has the same API\n\n## Usage\nSee examples below and in the [examples](./examples) directory.\n\n### Memory store\n```js\nconst client = new CacheManager({ store: 'memory', ttl: 10 /* seconds */ });\n\n// If the set method is called without ttl, the default ttl will be used\nawait client.set('foo', 'bar');\nawait client.get('foo'); // bar\nawait client.has('foo') // true\nawait client.has('baz'); // false\n\nawait sleep('10s');\nawait client.get('foo'); // undefined\nawait client.has('foo') // false\n\n// When ttl is defined, it will overwrite the default one\nawait client.set('foo', 'bar', 5);\nawait client.has('foo') // true\n\nawait sleep('5s');\nawait client.has('foo') // false\n\n// ttl = 0 means no expiration time\nawait client.set('foo', 'bar', 0);\n```\n\n### Redis store\n```js\nconst client = new CacheManager({\n  store: 'redis',\n  host: 'localhost',\n  port: 6379,\n  ttl: 10 /* seconds */\n});\n\nawait client.set('foo', 'bar');\nawait client.get('foo'); // bar\n```\n\n### Custom store\nYou can use your own custom store by creating one with the same API as the built-in memory stores (such as a memory or redis). See [example](./examples/custom-store.js).\n```js\nclass CustomStore { /* ... */ }\nconst client = new CacheManager({ store: CustomStore });\n\nawait client.set('foo', 'bar');\nawait client.get('foo'); // bar\n```\n\n### Serialization\nTapster uses `JSON.stringify` and `JSON.parse` for data serialization.\nYou can optionally provide your own serialization functions to support extra data types or to serialize to something other than JSON.\n```js\nconst cache = new CacheManager({ serialize: JSON.stringify, deserialize: JSON.parse });\n```\n\n### Namespaces\nNamespacing cache instance enables avoiding key collisions and allows clearing only a certain namespace while using the same database.\n```js\nconst users = new CacheManager({ namespace: 'users' });\nconst cars = new CacheManager({ namespace: 'cars' });\n\nawait users.set('record-1', 'John');\nawait cars.set('record-1', 'Honda');\n\nconsole.log('User keys: ', await users.getKeys()); // ['record-1'];\nconsole.log(await users.get('record-1')); // John\nconsole.log('Car keys: ', await cars.getKeys()); // ['record-1']\nconsole.log(await cars.get('record-1')); // Honda\n\nawait users.clear();\n\nconsole.log('User keys: ', await users.getKeys()); // []\nconsole.log(await users.get('record-1')); // undefined\nconsole.log('Car keys: ', await cars.getKeys()); // ['record-1']\nconsole.log(await cars.get('record-1')); // Honda\n```\n\n## Options\n### Common\n- `store` (optional) - built-in store (`memory`, `redis`) or custom store. Default is `memory`.\n- `ttl` (optional) - time to live in seconds. Default is `0`.\n- `namespace` (optional) - namespace cache instance to avoid key collisions. Default is `default`.\n### Redis store\n- `host` (required) - redis host.\n- `port` (required) - redis port.\n- `password` (optional) - redis password.\n\n## API\n- `set(key, value, ttl)` - TTL is optional. The cache manager instance's TTL will be used if the set method is called without a ttl parameter.\n- `get(key) =\u003e value`\n- `delete(key)`\n- `has(key)`\n- `clear` - Clear all records under the certain namespace\n- `getKeys(pattern) =\u003e keys`\n\nSupported glob-style patterns:\n- h?llo matches hello, hallo and hxllo\n- h*llo matches hllo and heeeello\n- h[ae]llo matches hello and hallo, but not hillo\n- h[^e]llo matches hallo, hbllo, ... but not hello\n- h[a-b]llo matches hallo and hbllo\n\n## Tests\nTo run tests run: \n```\nnpm t\n```\n\n## License\nTapster is licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextensionengine%2Ftapster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextensionengine%2Ftapster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextensionengine%2Ftapster/lists"}