{"id":15043551,"url":"https://github.com/redibox/cache","last_synced_at":"2025-04-14T21:13:27.150Z","repository":{"id":57147528,"uuid":"57253793","full_name":"redibox/cache","owner":"redibox","description":"Redis as a cache layer made simple.","archived":false,"fork":false,"pushed_at":"2017-01-06T11:18:01.000Z","size":27,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T21:13:22.060Z","etag":null,"topics":["cache","get","hooks","nodejs","promise","redibox","redis","sails","set","waterline"],"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/redibox.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":"2016-04-27T22:47:23.000Z","updated_at":"2023-03-10T11:56:02.000Z","dependencies_parsed_at":"2022-09-06T15:02:00.607Z","dependency_job_id":null,"html_url":"https://github.com/redibox/cache","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/redibox%2Fcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redibox%2Fcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redibox%2Fcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redibox%2Fcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redibox","download_url":"https://codeload.github.com/redibox/cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961237,"owners_count":21189993,"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","get","hooks","nodejs","promise","redibox","redis","sails","set","waterline"],"created_at":"2024-09-24T20:49:15.449Z","updated_at":"2025-04-14T21:13:27.111Z","avatar_url":"https://github.com/redibox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Coverage Status](https://coveralls.io/repos/github/redibox/cache/badge.svg?branch=master)](https://coveralls.io/github/redibox/cache?branch=master)\n![Downloads](https://img.shields.io/npm/dt/redibox-hook-cache.svg)\n[![npm version](https://img.shields.io/npm/v/redibox-hook-cache.svg)](https://www.npmjs.com/package/redibox-hook-cache)\n[![dependencies](https://img.shields.io/david/redibox/cache.svg)](https://david-dm.org/redibox/cache)\n[![build](https://travis-ci.org/redibox/cache.svg)](https://travis-ci.org/redibox/cache)\n[![License](https://img.shields.io/npm/l/redibox-hook-cache.svg)](/LICENSE)\n\n## RediBox Cache\n\nCache any data quickly and easily in Redis. Caching data is important to most applications. This hook handles various common requirements for caching data, specifically in Redis.\n\n### Installation\n\nFirst ensure you have [RediBox](https://github.com/redibox/core) installed.\n\nInstall Schedule via npm:\n\n`npm install redibox-hook-cache --save`\n\n### Usage\n\n#### Configure cache\n\n\u003e This hook will still work without setting any configuration options.\n\nWithin your `redibox` config, we'll setup a new `cache` object containing our configiration options:\n\n- **enabled** [Boolean]\n  - default: `true`\nIf disabled will by-pass any cached data.\n- **defaultTTL** [Number]\n  - default: `60`\nIn seconds, if no time to live (TTL) is specified, this is how long items to live in the cache for.\n- **keyPrefix** [String]\n  - default: `cache`\nThe namespace to store the cached items in Redis under. Shouldn't usually need changing.\n\n#### Basic API\n\n##### GET\n```javascript\n// Get data by key from the cache\nRediBox.hooks.cache.get('cat').then(data =\u003e {\n  console.log('Got a cat from cache', data);\n});\n```\n\n##### SET\n```javascript\n// Set data by key in the cache\nRediBox.hooks.cache.set('cat:fluffy', 'https://pbs.twimg.com/media/CYY44mYWMAATghb.jpg:small').then(() =\u003e {\n  console.log('Set a fluffy cat in cache');\n});\n```\n\n##### DEL\n```javascript\n// Delete an item by key in the cache\nRediBox.hooks.cache.del('cat').then(data =\u003e {\n  console.log('Deleted item');\n});\n```\n\n##### CLEAR\n```javascript\n// Delete all items in cache\nRediBox.hooks.cache.clear().then(data =\u003e {\n  console.log('Clear all data in cache');\n});\n\n// Delete all matching wildcard items in cache\nRediBox.hooks.cache.clear('cat:fluffy:*').then(data =\u003e {\n  console.log('Clear wildcard data from cache');\n});\n```\n\n### Advanced Usage\n\n- [API](https://github.com/redibox/cache/blob/master/docs/api.md)\n- [Caching Async Data](https://github.com/redibox/cache/blob/master/docs/caching-async-data.md)\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredibox%2Fcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredibox%2Fcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredibox%2Fcache/lists"}