{"id":24493053,"url":"https://github.com/open-node/open-cached","last_synced_at":"2025-03-15T03:29:51.584Z","repository":{"id":57149041,"uuid":"185553958","full_name":"open-node/open-cached","owner":"open-node","description":"cache by redis","archived":false,"fork":false,"pushed_at":"2019-05-08T09:27:20.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T22:36:44.904Z","etag":null,"topics":["async","cache-control","redis-cache"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-node.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-08T07:23:02.000Z","updated_at":"2020-03-19T03:59:02.000Z","dependencies_parsed_at":"2022-09-19T09:30:16.670Z","dependency_job_id":null,"html_url":"https://github.com/open-node/open-cached","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-node%2Fopen-cached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-node%2Fopen-cached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-node%2Fopen-cached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-node%2Fopen-cached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-node","download_url":"https://codeload.github.com/open-node/open-cached/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243680969,"owners_count":20330152,"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":["async","cache-control","redis-cache"],"created_at":"2025-01-21T19:19:00.199Z","updated_at":"2025-03-15T03:29:51.554Z","avatar_url":"https://github.com/open-node.png","language":"JavaScript","readme":"# Open-cached\n\nasync cache function, Base on ioredis with async/await\n\n[![Build status](https://api.travis-ci.org/open-node/open-cached.svg?branch=master)](https://travis-ci.org/open-node/open-cached)\n[![codecov](https://codecov.io/gh/open-node/open-cached/branch/master/graph/badge.svg)](https://codecov.io/gh/open-node/open-cached)\n\n## Node version\n\u003cpre\u003e \u003e= 8 \u003c/pre\u003e\n\n\n## Installation\n```bash\nnpm install open-cached --save\n```\n\n## Usage\n```javascript\nconst Redis = require(\"ioredis\");\nconst _ = require(\"lodash\");\nconst Cached = require('open-cached');\n\nconst redis = new Redis();\nconst cache = Cache(redis, _);\n```\n\n\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### Table of Contents\n\n-   [Cache][1]\n    -   [Parameters][2]\n    -   [get][3]\n        -   [Parameters][4]\n    -   [set][5]\n        -   [Parameters][6]\n    -   [del][7]\n        -   [Parameters][8]\n    -   [caching][9]\n        -   [Parameters][10]\n\n## Cache\n\n利用 redis 实现cache\n\n### Parameters\n\n-   `redis` **[object][11]** ioredis 实例\n-   `_` **[object][11]** lodash 库\n\nReturns **[Cache][12]** Instance\n\n### get\n\n获取缓存的值\n\n#### Parameters\n\n-   `key` **[string][13]** 缓存的 key\n\nReturns **Anyone** 缓存的值\n\n### set\n\n设置一个cache\n\n#### Parameters\n\n-   `key` **[string][13]** 缓存的 key\n-   `value` **[string][13]** 缓存的值\n-   `life` **[number][14]** 有效期，单位秒，默认 0 永久有效 (optional, default `0`)\n\nReturns **Anyone** 缓存的值\n\n### del\n\n删除缓存\n\n#### Parameters\n\n-   `key` **[string][13]** 缓存的 key\n\nReturns **[number][14]** 删除的条目数\n\n### caching\n\ncaching 让某个函数具有cache的能力\n\n#### Parameters\n\n-   `fn` **[function][15]** 要加工的函数\n-   `life` **[number][14]** 缓存有效期，单位秒\n-   `getKey` **[function][15]** 计算缓存key的函数\n\n[1]: #cache\n\n[2]: #parameters\n\n[3]: #get\n\n[4]: #parameters-1\n\n[5]: #set\n\n[6]: #parameters-2\n\n[7]: #del\n\n[8]: #parameters-3\n\n[9]: #caching\n\n[10]: #parameters-4\n\n[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\n\n[12]: #cache\n\n[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String\n\n[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number\n\n[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function\n\n\n### Contributing\n- Fork this repo\n- Clone your repo\n- Install dependencies\n- Checkout a feature branch\n- Feel free to add your features\n- Make sure your features are fully tested\n- Open a pull request, and enjoy \u003c3\n\n### MIT license\nCopyright (c) 2019 Open-node\nAuthor Redstone Zhao\nEmail: 13740080@qq.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \u0026quot;Software\u0026quot;), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \u0026quot;AS IS\u0026quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-node%2Fopen-cached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-node%2Fopen-cached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-node%2Fopen-cached/lists"}