{"action":"created","issue":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5823","repository_url":"https://api.github.com/repos/rethinkdb/rethinkdb","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5823/labels{/name}","comments_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5823/comments","events_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5823/events","html_url":"https://github.com/rethinkdb/rethinkdb/issues/5823","id":158272687,"number":5823,"title":"Proposal: Document expiration","user":{"login":"danielmewes","id":505365,"avatar_url":"https://avatars.githubusercontent.com/u/505365?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmewes","html_url":"https://github.com/danielmewes","followers_url":"https://api.github.com/users/danielmewes/followers","following_url":"https://api.github.com/users/danielmewes/following{/other_user}","gists_url":"https://api.github.com/users/danielmewes/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmewes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmewes/subscriptions","organizations_url":"https://api.github.com/users/danielmewes/orgs","repos_url":"https://api.github.com/users/danielmewes/repos","events_url":"https://api.github.com/users/danielmewes/events{/privacy}","received_events_url":"https://api.github.com/users/danielmewes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/labels/tp:ReQL_proposal","name":"tp:ReQL_proposal","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/120","html_url":"https://github.com/rethinkdb/rethinkdb/milestones/2.4","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/milestones/120/labels","id":1690485,"number":120,"title":"2.4","description":"","creator":{"login":"danielmewes","id":505365,"avatar_url":"https://avatars.githubusercontent.com/u/505365?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmewes","html_url":"https://github.com/danielmewes","followers_url":"https://api.github.com/users/danielmewes/followers","following_url":"https://api.github.com/users/danielmewes/following{/other_user}","gists_url":"https://api.github.com/users/danielmewes/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmewes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmewes/subscriptions","organizations_url":"https://api.github.com/users/danielmewes/orgs","repos_url":"https://api.github.com/users/danielmewes/repos","events_url":"https://api.github.com/users/danielmewes/events{/privacy}","received_events_url":"https://api.github.com/users/danielmewes/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":4,"state":"open","created_at":"2016-04-07T18:34:44Z","updated_at":"2016-06-06T19:07:06Z","due_on":null,"closed_at":null},"comments":27,"created_at":"2016-06-03T01:16:32Z","updated_at":"2016-06-15T22:54:51Z","closed_at":null,"body":"This proposal provides an implementation of TTL (https://github.com/rethinkdb/rethinkdb/issues/746) assuming the application code inserts documents with timestamps. It can be combined with https://github.com/rethinkdb/rethinkdb/issues/5813 to avoid that requirement on the application code.\r\n\r\nThe idea is to trigger deletions whenever the index value of a document passes the current time.\r\n\r\n__Configuration API__\r\n\r\nProposal for an API for configuring expiration on a given table:\r\n* `tbl.setExpiration(indexName[, replaceFunction])` sets expiration based on the given index `indexName`. Optionally, a custom function can be provided that allows writes other than deletion when a document expires (e.g. setting a flag on the document). The default is `replaceFunction = function(oldVal) { return null; }`.\r\n* `tbl.setExpiration(null)` disables expiration\r\n* `tbl.getExpiration()` retrieves the current expiration configuration\r\n\r\nThe `setExpiration` term requires `\"config\"` permissions on `tbl`.\r\n\r\n__Notes__\r\n\r\nCare must be taken when specifying a non-default `replaceFunction`. If the function fails to lower or remove the value of the index `indexName` for the document, expiration will not work (though we will catch this case, see below).\r\n\r\n__Implementation__\r\n\r\nRuns on each primary replica of the table:\r\n\r\n1. Run `tbl.between(r.minval, r.now, {index: indexName}).replace(replaceFunction)` limited to the shard's range\r\n2. Fetch `next = tbl.min({index: indexName})`, evaluate `nextTS = indexFunc(next)`, limited to the shard's range\r\n3. If `nextTS` is not a datetime, log an error, sleep indefinitely.\r\n  (Detail to detect bad `replaceFunction`: if `next` has the same primary key as the `next` from the previous iteration, print an error and sleep indefinitely as well.)\r\n  Otherwise, sleep for `nextTS - r.now`.\r\n  In either case, the sleep gets interrupted if any write on the primary's shard range\r\n  introduces an index value that's smaller than `nextTS`.\r\n4. Go to step 1"},"comment":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/comments/226343801","html_url":"https://github.com/rethinkdb/rethinkdb/issues/5823#issuecomment-226343801","issue_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5823","id":226343801,"user":{"login":"mlucy","id":1777134,"avatar_url":"https://avatars.githubusercontent.com/u/1777134?v=3","gravatar_id":"","url":"https://api.github.com/users/mlucy","html_url":"https://github.com/mlucy","followers_url":"https://api.github.com/users/mlucy/followers","following_url":"https://api.github.com/users/mlucy/following{/other_user}","gists_url":"https://api.github.com/users/mlucy/gists{/gist_id}","starred_url":"https://api.github.com/users/mlucy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlucy/subscriptions","organizations_url":"https://api.github.com/users/mlucy/orgs","repos_url":"https://api.github.com/users/mlucy/repos","events_url":"https://api.github.com/users/mlucy/events{/privacy}","received_events_url":"https://api.github.com/users/mlucy/received_events","type":"User","site_admin":false},"created_at":"2016-06-15T22:54:51Z","updated_at":"2016-06-15T22:54:51Z","body":"+1 for a proposal that we could extend to other types of eviction later."}}
{"actor":{"display_login":"mlucy"}}