{"action":"created","issue":{"url":"https://api.github.com/repos/yahoo/storage-lru/issues/14","labels_url":"https://api.github.com/repos/yahoo/storage-lru/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/yahoo/storage-lru/issues/14/comments","events_url":"https://api.github.com/repos/yahoo/storage-lru/issues/14/events","html_url":"https://github.com/yahoo/storage-lru/issues/14","id":99724942,"number":14,"title":"revalidateFn: README.md example incorect?","user":{"login":"jgchristian","id":596384,"avatar_url":"https://avatars.githubusercontent.com/u/596384?v=3","gravatar_id":"","url":"https://api.github.com/users/jgchristian","html_url":"https://github.com/jgchristian","followers_url":"https://api.github.com/users/jgchristian/followers","following_url":"https://api.github.com/users/jgchristian/following{/other_user}","gists_url":"https://api.github.com/users/jgchristian/gists{/gist_id}","starred_url":"https://api.github.com/users/jgchristian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgchristian/subscriptions","organizations_url":"https://api.github.com/users/jgchristian/orgs","repos_url":"https://api.github.com/users/jgchristian/repos","events_url":"https://api.github.com/users/jgchristian/events{/privacy}","received_events_url":"https://api.github.com/users/jgchristian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-07T20:25:44Z","updated_at":"2015-08-07T22:49:18Z","closed_at":null,"body":"Following the examples in the README.md, I specified options.revalidateFn as part of the setItem call, e.g.\r\n```javascript\r\nlru.setItem('fooJSON',{foo: 'bar'},\r\n    { \r\n        json: true,\r\n        cacheControl:'max-age=10,stale-while-revalidate=20',\r\n        revalidateFn: function(key, callback) {\r\n            console.log(\"revalidateFn called.\");\r\n        }\r\n    }, function (err) {}\r\n    }\r\n);\r\n```\r\n\r\nHowever, I never this this revalidate function being called.\r\n\r\nLooking in to the source, it appears that you should actually set this when creating the StorageLRU instance, rather than on the setItem call\r\n\r\ne.g.\r\n\r\n```javascript\r\nvar lru = new StorageLRU(asyncify(localStorage), \r\n    { revalidateFn: function(key, callback) {\r\n        console.log(\"revalidateFn called.\");\r\n    }\r\n});\r\n```\r\n\r\nThis seems to get fired as expected.\r\n\r\nNot sure if this is intended, so I didn't create a pull request on the README.md until I confirmed with you.\r\n\r\nJ"},"comment":{"url":"https://api.github.com/repos/yahoo/storage-lru/issues/comments/128852024","html_url":"https://github.com/yahoo/storage-lru/issues/14#issuecomment-128852024","issue_url":"https://api.github.com/repos/yahoo/storage-lru/issues/14","id":128852024,"user":{"login":"lingyan","id":1414235,"avatar_url":"https://avatars.githubusercontent.com/u/1414235?v=3","gravatar_id":"","url":"https://api.github.com/users/lingyan","html_url":"https://github.com/lingyan","followers_url":"https://api.github.com/users/lingyan/followers","following_url":"https://api.github.com/users/lingyan/following{/other_user}","gists_url":"https://api.github.com/users/lingyan/gists{/gist_id}","starred_url":"https://api.github.com/users/lingyan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lingyan/subscriptions","organizations_url":"https://api.github.com/users/lingyan/orgs","repos_url":"https://api.github.com/users/lingyan/repos","events_url":"https://api.github.com/users/lingyan/events{/privacy}","received_events_url":"https://api.github.com/users/lingyan/received_events","type":"User","site_admin":false},"created_at":"2015-08-07T22:49:17Z","updated_at":"2015-08-07T22:49:17Z","body":"@jgchristian You are absolutely correct.  Nice catch!\r\n\r\nThe description is README is correct, but the code example is clearly wrong :(  Please go ahead create a PR.  I'll be more than happy to merge it.\r\n\r\nThanks!\r\n"}}