GitHub IssueCommentEvent at 2015-01-01 22:39:31
Repository: WordPoints/wordpoints
Actor: JDGrimes
Payload: {"action":"created","issue":{"url":"https://api.github.com/repos/WordPoints/wordpoints/issues/203","labels_url":"https://api.github.com/repos/WordPoints/wordpoints/issues/203/labels{/name}","comments_url":"https://api.github.com/repos/WordPoints/wordpoints/issues/203/comments","events_url":"https://api.github.com/repos/WordPoints/wordpoints/issues/203/events","html_url":"https://github.com/WordPoints/wordpoints/issues/203","id":48171402,"number":203,"title":"Cache user ranks","user":{"login":"JDGrimes","id":4005415,"avatar_url":"https://avatars.githubusercontent.com/u/4005415?v=3","gravatar_id":"","url":"https://api.github.com/users/JDGrimes","html_url":"https://github.com/JDGrimes","followers_url":"https://api.github.com/users/JDGrimes/followers","following_url":"https://api.github.com/users/JDGrimes/following{/other_user}","gists_url":"https://api.github.com/users/JDGrimes/gists{/gist_id}","starred_url":"https://api.github.com/users/JDGrimes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDGrimes/subscriptions","organizations_url":"https://api.github.com/users/JDGrimes/orgs","repos_url":"https://api.github.com/users/JDGrimes/repos","events_url":"https://api.github.com/users/JDGrimes/events{/privacy}","received_events_url":"https://api.github.com/users/JDGrimes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/WordPoints/wordpoints/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"JDGrimes","id":4005415,"avatar_url":"https://avatars.githubusercontent.com/u/4005415?v=3","gravatar_id":"","url":"https://api.github.com/users/JDGrimes","html_url":"https://github.com/JDGrimes","followers_url":"https://api.github.com/users/JDGrimes/followers","following_url":"https://api.github.com/users/JDGrimes/following{/other_user}","gists_url":"https://api.github.com/users/JDGrimes/gists{/gist_id}","starred_url":"https://api.github.com/users/JDGrimes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDGrimes/subscriptions","organizations_url":"https://api.github.com/users/JDGrimes/orgs","repos_url":"https://api.github.com/users/JDGrimes/repos","events_url":"https://api.github.com/users/JDGrimes/events{/privacy}","received_events_url":"https://api.github.com/users/JDGrimes/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/WordPoints/wordpoints/milestones/11","labels_url":"https://api.github.com/repos/WordPoints/wordpoints/milestones/11/labels","id":884448,"number":11,"title":"1.9.0","description":"This will mainly be a cleanup release, with few obvious features plan.","creator":{"login":"JDGrimes","id":4005415,"avatar_url":"https://avatars.githubusercontent.com/u/4005415?v=3","gravatar_id":"","url":"https://api.github.com/users/JDGrimes","html_url":"https://github.com/JDGrimes","followers_url":"https://api.github.com/users/JDGrimes/followers","following_url":"https://api.github.com/users/JDGrimes/following{/other_user}","gists_url":"https://api.github.com/users/JDGrimes/gists{/gist_id}","starred_url":"https://api.github.com/users/JDGrimes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDGrimes/subscriptions","organizations_url":"https://api.github.com/users/JDGrimes/orgs","repos_url":"https://api.github.com/users/JDGrimes/repos","events_url":"https://api.github.com/users/JDGrimes/events{/privacy}","received_events_url":"https://api.github.com/users/JDGrimes/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":11,"state":"open","created_at":"2014-11-29T20:26:14Z","updated_at":"2015-01-01T17:08:12Z","due_on":"2015-01-31T05:00:00Z","closed_at":null},"comments":1,"created_at":"2014-11-08T17:03:26Z","updated_at":"2015-01-01T22:39:30Z","closed_at":null,"body":"Right now we cache ranks themselves, but not which ranks which users have."},"comment":{"url":"https://api.github.com/repos/WordPoints/wordpoints/issues/comments/68500849","html_url":"https://github.com/WordPoints/wordpoints/issues/203#issuecomment-68500849","issue_url":"https://api.github.com/repos/WordPoints/wordpoints/issues/203","id":68500849,"user":{"login":"JDGrimes","id":4005415,"avatar_url":"https://avatars.githubusercontent.com/u/4005415?v=3","gravatar_id":"","url":"https://api.github.com/users/JDGrimes","html_url":"https://github.com/JDGrimes","followers_url":"https://api.github.com/users/JDGrimes/followers","following_url":"https://api.github.com/users/JDGrimes/following{/other_user}","gists_url":"https://api.github.com/users/JDGrimes/gists{/gist_id}","starred_url":"https://api.github.com/users/JDGrimes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDGrimes/subscriptions","organizations_url":"https://api.github.com/users/JDGrimes/orgs","repos_url":"https://api.github.com/users/JDGrimes/repos","events_url":"https://api.github.com/users/JDGrimes/events{/privacy}","received_events_url":"https://api.github.com/users/JDGrimes/received_events","type":"User","site_admin":false},"created_at":"2015-01-01T22:39:30Z","updated_at":"2015-01-01T22:39:30Z","body":"There is the possibility of having two caches here. One cache for `wordpoints_get_user_rank()`, which would be the `wordpoints_user_rank` group and the cache key would be like `$user_id|$group`. The second would be for `wordpoints_get_users_with_rank()` and would be the `wordpoints_users_with_rank` group, the key would be the rank ID.\r\n\r\nThis works nicely, I think, with one issue. When a rank is moved or deleted we have to pull the IDs of all the users who have that rank just to properly clear the cache. We can clear the `wordpoints_users_with_rank` cache group easily, the issue is only with the `wordpoints_user_rank` group. We currently just run an `UPDATE` query when a rank is moved/removed in a group. That will have to change it we want to invalidate the cache properly. In truth, we should probably be using `wordpoints_update_user_rank()` in both cases, so that all of the correct actions get called in addition to our caching purposes. However, I don't know if that would lead to unexpected behavior. In other words, it needs to be investigated. The biggest concern with this is that with large sites we'll have timeout or memory issues when looping through all the users with a rank. But maybe there is a good solution for that? It's something that has been an issue with the ranks since day one, but we bypassed it via that simple `UPDATE` query.\r\n\r\nThere are actually other possibilities, but they may not be much good. We could, for example, scrap the `wordpoints_user_rank` cache group completely, and just use the `wordpoints_users_with_rank` cache when it is loaded. I don't think we'd want to run a call to `wordpoints_get_users_with_rank()` every time we just want to get the rank of a single user, so we'd probably want to only use the cache when it is loaded."}}