{"action":"created","issue":{"url":"https://api.github.com/repos/request/request/issues/1604","labels_url":"https://api.github.com/repos/request/request/issues/1604/labels{/name}","comments_url":"https://api.github.com/repos/request/request/issues/1604/comments","events_url":"https://api.github.com/repos/request/request/issues/1604/events","html_url":"https://github.com/request/request/issues/1604","id":81547782,"number":1604,"title":"Thoughts on a cache wrapper","user":{"login":"phillipj","id":1231635,"avatar_url":"https://avatars.githubusercontent.com/u/1231635?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipj","html_url":"https://github.com/phillipj","followers_url":"https://api.github.com/users/phillipj/followers","following_url":"https://api.github.com/users/phillipj/following{/other_user}","gists_url":"https://api.github.com/users/phillipj/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipj/subscriptions","organizations_url":"https://api.github.com/users/phillipj/orgs","repos_url":"https://api.github.com/users/phillipj/repos","events_url":"https://api.github.com/users/phillipj/events{/privacy}","received_events_url":"https://api.github.com/users/phillipj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-05-27T17:39:39Z","updated_at":"2015-08-26T18:19:26Z","closed_at":null,"body":"Hi!\r\n\r\nI'm been thinking about creating (yet another) cache wrapper around `request`. Before jumping into coding something, I would really appreciate some thoughts from you on this as I'm guessing you have done some thinking around caching more than once over the years.\r\n\r\nIn comparison to the other caching modules I have found so far, I want to do a slightly different approach by literally wrapping instead of being a drop-in-replacement. Somewhat inspired by the wrapping/interceptors done in the [rest](https://github.com/cujojs/rest) module.\r\n\r\n```js\r\n// something similar to\r\nvar cache = require('request-cache');\r\nvar request = cache(require('request'));\r\n\r\n// not drop-in such as\r\nvar request = require('a-request-cache-module');\r\n```\r\n\r\nIn my mind **actually** wrapping like that looks more like actual composition which I'm a big fan of.\r\n\r\nAny thoughts on this? Is there room for another cache module or does it already exist a good enough cache module out there?"},"comment":{"url":"https://api.github.com/repos/request/request/issues/comments/135129363","html_url":"https://github.com/request/request/issues/1604#issuecomment-135129363","issue_url":"https://api.github.com/repos/request/request/issues/1604","id":135129363,"user":{"login":"phillipj","id":1231635,"avatar_url":"https://avatars.githubusercontent.com/u/1231635?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipj","html_url":"https://github.com/phillipj","followers_url":"https://api.github.com/users/phillipj/followers","following_url":"https://api.github.com/users/phillipj/following{/other_user}","gists_url":"https://api.github.com/users/phillipj/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipj/subscriptions","organizations_url":"https://api.github.com/users/phillipj/orgs","repos_url":"https://api.github.com/users/phillipj/repos","events_url":"https://api.github.com/users/phillipj/events{/privacy}","received_events_url":"https://api.github.com/users/phillipj/received_events","type":"User","site_admin":false},"created_at":"2015-08-26T18:19:26Z","updated_at":"2015-08-26T18:19:26Z","body":"@mcollina very good point about not changing the request module globally!\r\n\r\n@pyhedgehog @BrandonCopley thanks for your thoughts about what you expect to be cached.\r\n\r\n@BrandonCopley *each* request or a group of requests? Pseudocode of the what I think is the difference:\r\n\r\n```js\r\n// option 1 : different cache per request\r\n\r\nvar cache = require('request-cache')\r\n  , request = cache(require('request'))\r\n  ;\r\n\r\nvar sqlCache = {cache:'cachefile.sqlite'}\r\n  , redisCache = {cache:'redis'}\r\n  ;\r\n\r\nrequest.get('http://www.google.com', sqlCache)\r\nrequest.get('http://www.facebook.com', redisCache)\r\n\r\n// option 2 : different cache per group\r\n\r\nvar cache = require('request-cache')\r\n  , request = require('request'),\r\n  , searchRequest = cache(request, {cache:'cachefile.sqlite'}),\r\n  , socialRequest = cache(request, {cache:'redis'})\r\n  ;\r\n\r\nsearchRequest.get('http://www.google.com')\r\nsocialRequest.get('http://www.facebook.com')\r\n```\r\n\r\n"}}