{"id":24112446,"url":"https://github.com/dabroek/node-cache-manager-redis-store","last_synced_at":"2025-04-12T17:45:41.441Z","repository":{"id":20479098,"uuid":"90023310","full_name":"dabroek/node-cache-manager-redis-store","owner":"dabroek","description":"Redis store for node-cache-manager using node_redis.","archived":false,"fork":false,"pushed_at":"2023-12-28T11:50:02.000Z","size":589,"stargazers_count":170,"open_issues_count":21,"forks_count":57,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T21:26:47.163Z","etag":null,"topics":["cache","cache-manager","es2015","es6","redis","redis-client","redis-store"],"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/dabroek.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}},"created_at":"2017-05-02T11:00:31.000Z","updated_at":"2024-10-16T22:11:05.000Z","dependencies_parsed_at":"2024-06-18T12:42:11.653Z","dependency_job_id":null,"html_url":"https://github.com/dabroek/node-cache-manager-redis-store","commit_stats":{"total_commits":47,"total_committers":7,"mean_commits":6.714285714285714,"dds":0.5106382978723405,"last_synced_commit":"04d04cb5e5a472a9f8eb78c59fa1f90eb6df5839"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabroek%2Fnode-cache-manager-redis-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabroek%2Fnode-cache-manager-redis-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabroek%2Fnode-cache-manager-redis-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabroek%2Fnode-cache-manager-redis-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dabroek","download_url":"https://codeload.github.com/dabroek/node-cache-manager-redis-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248609552,"owners_count":21132916,"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","cache-manager","es2015","es6","redis","redis-client","redis-store"],"created_at":"2025-01-11T03:31:47.317Z","updated_at":"2025-04-12T17:45:41.424Z","avatar_url":"https://github.com/dabroek.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/cache-manager-redis-store.svg)](https://badge.fury.io/js/cache-manager-redis-store)\n[![GitHub issues](https://img.shields.io/github/issues/dabroek/node-cache-manager-redis-store.svg)](https://github.com/dabroek/node-cache-manager-redis-store/issues)\n[![codecov](https://codecov.io/github/dabroek/node-cache-manager-redis-store/branch/master/graph/badge.svg?token=QmCNGyCLlD)](https://codecov.io/github/dabroek/node-cache-manager-redis-store)\n\nRedis store for node cache manager\n==================================\n\nRedis cache store for [node-cache-manager](https://github.com/BryanDonovan/node-cache-manager).\n\nHow is this package different from `node-cache-manager-redis`?\n----------------------------------------------------------------------------------\nThis is a **completely different version** than the earlier [node-cache-manager-redis](https://github.com/dial-once/node-cache-manager-redis). This package does not use `redis-pool` which is unnecessary and not actively maintained.\n\nThis package aims to provide **the most simple wrapper possible** by just passing the configuration to the underlying `node_redis` package.\n\nInstallation\n------------\n\n```sh\nnpm install cache-manager-redis-store --save\n```\nor\n```sh\nyarn add cache-manager-redis-store\n```\n\nUsage Examples\n--------------\n\nSee examples below on how to implement the Redis cache store.\n\n### Single store\n\n```js\nvar cacheManager = require('cache-manager');\nvar redisStore = require('cache-manager-redis-store').redisStore;\n\nvar config = {\n  socket: {\n    host: 'localhost', // default value\n    port: 6379, // default value\n  },\n  password: 'XXXXX',\n  db: 0,\n  ttl: 600\n};\n\nvar redisCache = cacheManager.caching({\n  store: await redisStore(config),\n});\n\n// listen for redis connection error event\nvar redisClient = redisCache.store.getClient();\n\nredisClient.on('error', (error) =\u003e {\n  // handle error here\n  console.log(error);\n});\n\nvar ttl = 5;\n\nawait redisCache.set('foo', 'bar', { ttl: ttl });\n\n// You can use either a Promise...\nvar result = await redisCache.get('foo');\nconsole.log(result);\n\n// ...or a callback\nredisCache.get('foo', (err, result) =\u003e {\n  if (err) {\n    // handle error here\n  }\n  console.log(result);\n});\n\n// \u003e\u003e 'bar'\nconsole.log(await redisCache.del('foo'));\n// \u003e\u003e 1\n\nfunction getUser(id, cb) {\n  setTimeout(() =\u003e {\n    console.log(\"Returning user from slow database.\");\n    cb(null, { id: id, name: 'Bob' });\n  }, 100);\n}\n\nvar userId = 123;\nvar key = `user_${userId}`;\n\n// Note: ttl is optional in wrap()\nredisCache.wrap(key, (cb) =\u003e {\n  getUser(userId, cb);\n}, { ttl: ttl }, (err, user) =\u003e {\n  console.log(user);\n\n  // Second time fetches user from redisCache\n  redisCache\n    .wrap(key, () =\u003e getUser(userId))\n    .then(console.log)\n    .catch(err =\u003e {\n      // handle error\n    });\n});\n```\n\n### Multi-store\n\n```js\nvar cacheManager = require('cache-manager');\nvar redisStore = require('cache-manager-redis-store').redisStore;\n\nvar redisCache = cacheManager.caching({ store: await redisStore({ ...config, db: 0, ttl: 600 }) });\nvar memoryCache = cacheManager.caching({ store: 'memory', max: 100, ttl: 60 });\n\nvar multiCache = cacheManager.multiCaching([memoryCache, redisCache]);\n\nvar userId2 = 456;\nvar key2 = `user_${userId2}`;\n\n// Set value in all caches\nawait multiCache.set('foo2', 'bar2', { ttl: ttl });\n// Fetches from highest priority cache that has the key\nvar result = await multiCache.get('foo2');\nconsole.log(result);\n// \u003e\u003e 'bar2'\n\n// Delete from all caches\nawait multiCache.del('foo2');\n\n// Note: ttl is optional in wrap\nmultiCache.wrap(key2, (cb) =\u003e {\n  getUser(userId2, cb);\n}, (err, user) =\u003e {\n  console.log(user);\n\n  // Second time fetches user from memoryCache, since it's highest priority.\n  // If the data expires in the memory cache, the next fetch would pull it from\n  // the 'someOtherCache', and set the data in memory again.\n  multiCache.wrap(key2, (cb) =\u003e {\n    getUser(userId2, cb);\n  }, (err, user) =\u003e {\n    console.log(user);\n  });\n});\n```\n\nContribution\n------------\n\nWant to help improve this package? We take [pull requests](https://github.com/dabroek/node-cache-manager-redis-store/pulls).\n\n\nLicense\n-------\n\nThe `node-cache-manager-redis-store` is licensed under the MIT license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabroek%2Fnode-cache-manager-redis-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabroek%2Fnode-cache-manager-redis-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabroek%2Fnode-cache-manager-redis-store/lists"}