{"action":"created","issue":{"url":"https://api.github.com/repos/mpneuried/nodecache/issues/78","repository_url":"https://api.github.com/repos/mpneuried/nodecache","labels_url":"https://api.github.com/repos/mpneuried/nodecache/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/mpneuried/nodecache/issues/78/comments","events_url":"https://api.github.com/repos/mpneuried/nodecache/issues/78/events","html_url":"https://github.com/mpneuried/nodecache/issues/78","id":196228216,"number":78,"title":"checkperiod only trigger once?","user":{"login":"JimmyHwang","id":38301,"avatar_url":"https://avatars.githubusercontent.com/u/38301?v=3","gravatar_id":"","url":"https://api.github.com/users/JimmyHwang","html_url":"https://github.com/JimmyHwang","followers_url":"https://api.github.com/users/JimmyHwang/followers","following_url":"https://api.github.com/users/JimmyHwang/following{/other_user}","gists_url":"https://api.github.com/users/JimmyHwang/gists{/gist_id}","starred_url":"https://api.github.com/users/JimmyHwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimmyHwang/subscriptions","organizations_url":"https://api.github.com/users/JimmyHwang/orgs","repos_url":"https://api.github.com/users/JimmyHwang/repos","events_url":"https://api.github.com/users/JimmyHwang/events{/privacy}","received_events_url":"https://api.github.com/users/JimmyHwang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-17T15:50:07Z","updated_at":"2016-12-19T05:32:13Z","closed_at":null,"body":"I tried following code, but seems only show \"A:1 is expired\", \"A:2\" never be show\r\n\r\nvar myCache = new node_cache( { stdTTL: 50, checkperiod: 20 } );\r\nmyCache.set(\"A:1\", Code, 10);\r\nmyCache.set(\"A:2\", Code, 25);\r\n\r\nmyCache.on(\"expired\", function( key, value ){\r\n  console.log(key + \" is expired\");\r\n  // ... do something ...   \r\n});\r\n\r\nHow can make it run the expired check by interval?"},"comment":{"url":"https://api.github.com/repos/mpneuried/nodecache/issues/comments/267885338","html_url":"https://github.com/mpneuried/nodecache/issues/78#issuecomment-267885338","issue_url":"https://api.github.com/repos/mpneuried/nodecache/issues/78","id":267885338,"user":{"login":"mpneuried","id":300631,"avatar_url":"https://avatars.githubusercontent.com/u/300631?v=3","gravatar_id":"","url":"https://api.github.com/users/mpneuried","html_url":"https://github.com/mpneuried","followers_url":"https://api.github.com/users/mpneuried/followers","following_url":"https://api.github.com/users/mpneuried/following{/other_user}","gists_url":"https://api.github.com/users/mpneuried/gists{/gist_id}","starred_url":"https://api.github.com/users/mpneuried/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpneuried/subscriptions","organizations_url":"https://api.github.com/users/mpneuried/orgs","repos_url":"https://api.github.com/users/mpneuried/repos","events_url":"https://api.github.com/users/mpneuried/events{/privacy}","received_events_url":"https://api.github.com/users/mpneuried/received_events","type":"User","site_admin":false},"created_at":"2016-12-19T05:32:13Z","updated_at":"2016-12-19T05:32:13Z","body":"probably your script will just end before your defined ttl's expire.\r\ni use [`.unref()`](https://github.com/mpneuried/nodecache/blob/master/_src/lib/node_cache.coffee#L480) to prevent node-cache from blocking your script to exit.\r\nSo if your script ends teh process will stopped.\r\n\r\nYou can just run your own timeout like this example:\r\n```js\r\nvar node_cache = require(\"node-cache\");\r\nvar myCache = new node_cache( { stdTTL: 50, checkperiod: 2 } );\r\nmyCache.set(\"A:1\", 123, 5);\r\nmyCache.set(\"A:2\", 456, 10);\r\n\r\nmyCache.on(\"expired\", function( key, value ){\r\n  console.log(key + \" is expired\");\r\n  // ... do something ...\r\n});\r\nconsole.log( \"waiting ... \" );\r\n\r\n// add a timeout to prevent the script to exit\r\nsetTimeout( function(  ){\r\n  console.log( \"exit\" );\r\n}, 15000 )\r\n```\r\n> See working example here: https://runkit.com/mpneuried/58576ddb558ed60013d25574"}}
{"actor":{"display_login":"mpneuried"}}