{"action":"created","issue":{"url":"https://api.github.com/repos/walterhiggins/ScriptCraft/issues/270","labels_url":"https://api.github.com/repos/walterhiggins/ScriptCraft/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/walterhiggins/ScriptCraft/issues/270/comments","events_url":"https://api.github.com/repos/walterhiggins/ScriptCraft/issues/270/events","html_url":"https://github.com/walterhiggins/ScriptCraft/pull/270","id":105838632,"number":270,"title":"Allow periodic saving in `persist()`","user":{"login":"frash23","id":8148752,"avatar_url":"https://avatars.githubusercontent.com/u/8148752?v=3","gravatar_id":"","url":"https://api.github.com/users/frash23","html_url":"https://github.com/frash23","followers_url":"https://api.github.com/users/frash23/followers","following_url":"https://api.github.com/users/frash23/following{/other_user}","gists_url":"https://api.github.com/users/frash23/gists{/gist_id}","starred_url":"https://api.github.com/users/frash23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frash23/subscriptions","organizations_url":"https://api.github.com/users/frash23/orgs","repos_url":"https://api.github.com/users/frash23/repos","events_url":"https://api.github.com/users/frash23/events{/privacy}","received_events_url":"https://api.github.com/users/frash23/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-10T15:51:30Z","updated_at":"2015-09-10T17:40:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/walterhiggins/ScriptCraft/pulls/270","html_url":"https://github.com/walterhiggins/ScriptCraft/pull/270","diff_url":"https://github.com/walterhiggins/ScriptCraft/pull/270.diff","patch_url":"https://github.com/walterhiggins/ScriptCraft/pull/270.patch"},"body":"I think not having a clean way to schedule saving data is a big flaw.\r\nI've tested this shortly and it appears to be working fine, although I'd recommend making sure it appears to function as expected on your end as well.\r\n\r\nYou could throw in a default value as well if you'd like."},"comment":{"url":"https://api.github.com/repos/walterhiggins/ScriptCraft/issues/comments/139321489","html_url":"https://github.com/walterhiggins/ScriptCraft/pull/270#issuecomment-139321489","issue_url":"https://api.github.com/repos/walterhiggins/ScriptCraft/issues/270","id":139321489,"user":{"login":"frash23","id":8148752,"avatar_url":"https://avatars.githubusercontent.com/u/8148752?v=3","gravatar_id":"","url":"https://api.github.com/users/frash23","html_url":"https://github.com/frash23","followers_url":"https://api.github.com/users/frash23/followers","following_url":"https://api.github.com/users/frash23/following{/other_user}","gists_url":"https://api.github.com/users/frash23/gists{/gist_id}","starred_url":"https://api.github.com/users/frash23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frash23/subscriptions","organizations_url":"https://api.github.com/users/frash23/orgs","repos_url":"https://api.github.com/users/frash23/repos","events_url":"https://api.github.com/users/frash23/events{/privacy}","received_events_url":"https://api.github.com/users/frash23/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T17:40:52Z","updated_at":"2015-09-10T17:40:52Z","body":"Having no control over the timer is definitely an issue, didn't think of that.\r\nI'm just not a fan of this approach, it feels dirty. I guess that might just be me.\r\n\r\nCurrently I have a small library of functions I use for my own projects where I have my own method which instead of returning the data itself returns a map with one of the properties being the actual data while also packing some other stuff like .save():\r\n\r\n```\r\nvar cache = fLib.persist('myCache', defaultData, 60);\r\n\r\nconsole.log(myCache.data); // The actual data\r\nmyCache.save(); // Force a write\r\nclearInterval( myCache.intervalId ); // Stop scheduled writing\r\n```\r\nBut this is different behavior from your persist module, which is why I sent this patch.\r\nI'm just afraid someone not fully understanding the code behind `persist()` start using it for their long-running server and ends up losing loads of important data due to i.e. a power loss or forced reboot."}}