{"action":"created","comment":{"url":"https://api.github.com/repos/springernature/bandiera/pulls/comments/139350816","pull_request_review_id":63269600,"id":139350816,"diff_hunk":"@@ -0,0 +1,71 @@\n+# frozen_string_literal: true\n+\n+require 'lru_redux'\n+\n+module Bandiera\n+  class CachingFeatureService < SimpleDelegator\n+    CACHE_SIZE = 100\n+    CACHE_TTL  = 10\n+\n+    attr_reader :cache\n+\n+    def initialize(delegate)\n+      @cache = LruRedux::TTL::ThreadSafeCache.new(CACHE_SIZE, CACHE_TTL)","path":"lib/bandiera/caching_feature_service.rb","position":13,"original_position":13,"commit_id":"045f1f3086bc189d50910ca6be015e4612f37335","original_commit_id":"e45d572588cf260523df6ae8cc3e90ae57134818","user":{"login":"jshiell","id":1030482,"avatar_url":"https://avatars0.githubusercontent.com/u/1030482?v=4","gravatar_id":"","url":"https://api.github.com/users/jshiell","html_url":"https://github.com/jshiell","followers_url":"https://api.github.com/users/jshiell/followers","following_url":"https://api.github.com/users/jshiell/following{/other_user}","gists_url":"https://api.github.com/users/jshiell/gists{/gist_id}","starred_url":"https://api.github.com/users/jshiell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jshiell/subscriptions","organizations_url":"https://api.github.com/users/jshiell/orgs","repos_url":"https://api.github.com/users/jshiell/repos","events_url":"https://api.github.com/users/jshiell/events{/privacy}","received_events_url":"https://api.github.com/users/jshiell/received_events","type":"User","site_admin":false},"body":"Looks great, thanks - very happy to replace custom code with something battle tested 😄 ","created_at":"2017-09-18T07:32:02Z","updated_at":"2017-09-18T07:32:02Z","html_url":"https://github.com/springernature/bandiera/pull/80#discussion_r139350816","pull_request_url":"https://api.github.com/repos/springernature/bandiera/pulls/80","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/springernature/bandiera/pulls/comments/139350816"},"html":{"href":"https://github.com/springernature/bandiera/pull/80#discussion_r139350816"},"pull_request":{"href":"https://api.github.com/repos/springernature/bandiera/pulls/80"}},"in_reply_to_id":139118434},"pull_request":{"url":"https://api.github.com/repos/springernature/bandiera/pulls/80","id":141074320,"html_url":"https://github.com/springernature/bandiera/pull/80","diff_url":"https://github.com/springernature/bandiera/pull/80.diff","patch_url":"https://github.com/springernature/bandiera/pull/80.patch","issue_url":"https://api.github.com/repos/springernature/bandiera/issues/80","number":80,"state":"open","locked":false,"title":"Add local in-memory read-through cache for feature service","user":{"login":"jshiell","id":1030482,"avatar_url":"https://avatars0.githubusercontent.com/u/1030482?v=4","gravatar_id":"","url":"https://api.github.com/users/jshiell","html_url":"https://github.com/jshiell","followers_url":"https://api.github.com/users/jshiell/followers","following_url":"https://api.github.com/users/jshiell/following{/other_user}","gists_url":"https://api.github.com/users/jshiell/gists{/gist_id}","starred_url":"https://api.github.com/users/jshiell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jshiell/subscriptions","organizations_url":"https://api.github.com/users/jshiell/orgs","repos_url":"https://api.github.com/users/jshiell/repos","events_url":"https://api.github.com/users/jshiell/events{/privacy}","received_events_url":"https://api.github.com/users/jshiell/received_events","type":"User","site_admin":false},"body":"This PR introduces a facading cache to the `FeatureService` in order to improve resilience and performance.\r\n\r\nIt's a fairly naive implementation to begin with - it invalidates itself on writes, and only caches for 10s, which appears to result in a satisfactory user experience when testing in a multiple node setup (the production Nature instances). It also substantially improves response times (50-70%) and reduces CPU by about 25% when running at ~125 requests/s.\r\n\r\nIt also provides an entry point for future resilience enhancements, such as continuing to use memory cached data if the database becomes inaccessible.\r\n\r\nThis is a backport from the AppAnatomy compliant fork used for Nature.","created_at":"2017-09-14T13:28:29Z","updated_at":"2017-09-18T07:32:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b14a56f229495dcb0fee24ed0c676fd96867e4d2","assignee":null,"assignees":[],"requested_reviewers":[{"login":"JasmoMyer","id":1262801,"avatar_url":"https://avatars2.githubusercontent.com/u/1262801?v=4","gravatar_id":"","url":"https://api.github.com/users/JasmoMyer","html_url":"https://github.com/JasmoMyer","followers_url":"https://api.github.com/users/JasmoMyer/followers","following_url":"https://api.github.com/users/JasmoMyer/following{/other_user}","gists_url":"https://api.github.com/users/JasmoMyer/gists{/gist_id}","starred_url":"https://api.github.com/users/JasmoMyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasmoMyer/subscriptions","organizations_url":"https://api.github.com/users/JasmoMyer/orgs","repos_url":"https://api.github.com/users/JasmoMyer/repos","events_url":"https://api.github.com/users/JasmoMyer/events{/privacy}","received_events_url":"https://api.github.com/users/JasmoMyer/received_events","type":"User","site_admin":false},{"login":"josebolos","id":1792637,"avatar_url":"https://avatars0.githubusercontent.com/u/1792637?v=4","gravatar_id":"","url":"https://api.github.com/users/josebolos","html_url":"https://github.com/josebolos","followers_url":"https://api.github.com/users/josebolos/followers","following_url":"https://api.github.com/users/josebolos/following{/other_user}","gists_url":"https://api.github.com/users/josebolos/gists{/gist_id}","starred_url":"https://api.github.com/users/josebolos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josebolos/subscriptions","organizations_url":"https://api.github.com/users/josebolos/orgs","repos_url":"https://api.github.com/users/josebolos/repos","events_url":"https://api.github.com/users/josebolos/events{/privacy}","received_events_url":"https://api.github.com/users/josebolos/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/springernature/bandiera/pulls/80/commits","review_comments_url":"https://api.github.com/repos/springernature/bandiera/pulls/80/comments","review_comment_url":"https://api.github.com/repos/springernature/bandiera/pulls/comments{/number}","comments_url":"https://api.github.com/repos/springernature/bandiera/issues/80/comments","statuses_url":"https://api.github.com/repos/springernature/bandiera/statuses/045f1f3086bc189d50910ca6be015e4612f37335","head":{"label":"springernature:feature-service-caching","ref":"feature-service-caching","sha":"045f1f3086bc189d50910ca6be015e4612f37335","user":{"login":"springernature","id":13002186,"avatar_url":"https://avatars2.githubusercontent.com/u/13002186?v=4","gravatar_id":"","url":"https://api.github.com/users/springernature","html_url":"https://github.com/springernature","followers_url":"https://api.github.com/users/springernature/followers","following_url":"https://api.github.com/users/springernature/following{/other_user}","gists_url":"https://api.github.com/users/springernature/gists{/gist_id}","starred_url":"https://api.github.com/users/springernature/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/springernature/subscriptions","organizations_url":"https://api.github.com/users/springernature/orgs","repos_url":"https://api.github.com/users/springernature/repos","events_url":"https://api.github.com/users/springernature/events{/privacy}","received_events_url":"https://api.github.com/users/springernature/received_events","type":"Organization","site_admin":false},"repo":{"id":14398758,"name":"bandiera","full_name":"springernature/bandiera","owner":{"login":"springernature","id":13002186,"avatar_url":"https://avatars2.githubusercontent.com/u/13002186?v=4","gravatar_id":"","url":"https://api.github.com/users/springernature","html_url":"https://github.com/springernature","followers_url":"https://api.github.com/users/springernature/followers","following_url":"https://api.github.com/users/springernature/following{/other_user}","gists_url":"https://api.github.com/users/springernature/gists{/gist_id}","starred_url":"https://api.github.com/users/springernature/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/springernature/subscriptions","organizations_url":"https://api.github.com/users/springernature/orgs","repos_url":"https://api.github.com/users/springernature/repos","events_url":"https://api.github.com/users/springernature/events{/privacy}","received_events_url":"https://api.github.com/users/springernature/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/springernature/bandiera","description":"Simple Feature Flagging","fork":false,"url":"https://api.github.com/repos/springernature/bandiera","forks_url":"https://api.github.com/repos/springernature/bandiera/forks","keys_url":"https://api.github.com/repos/springernature/bandiera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/springernature/bandiera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/springernature/bandiera/teams","hooks_url":"https://api.github.com/repos/springernature/bandiera/hooks","issue_events_url":"https://api.github.com/repos/springernature/bandiera/issues/events{/number}","events_url":"https://api.github.com/repos/springernature/bandiera/events","assignees_url":"https://api.github.com/repos/springernature/bandiera/assignees{/user}","branches_url":"https://api.github.com/repos/springernature/bandiera/branches{/branch}","tags_url":"https://api.github.com/repos/springernature/bandiera/tags","blobs_url":"https://api.github.com/repos/springernature/bandiera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/springernature/bandiera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/springernature/bandiera/git/refs{/sha}","trees_url":"https://api.github.com/repos/springernature/bandiera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/springernature/bandiera/statuses/{sha}","languages_url":"https://api.github.com/repos/springernature/bandiera/languages","stargazers_url":"https://api.github.com/repos/springernature/bandiera/stargazers","contributors_url":"https://api.github.com/repos/springernature/bandiera/contributors","subscribers_url":"https://api.github.com/repos/springernature/bandiera/subscribers","subscription_url":"https://api.github.com/repos/springernature/bandiera/subscription","commits_url":"https://api.github.com/repos/springernature/bandiera/commits{/sha}","git_commits_url":"https://api.github.com/repos/springernature/bandiera/git/commits{/sha}","comments_url":"https://api.github.com/repos/springernature/bandiera/comments{/number}","issue_comment_url":"https://api.github.com/repos/springernature/bandiera/issues/comments{/number}","contents_url":"https://api.github.com/repos/springernature/bandiera/contents/{+path}","compare_url":"https://api.github.com/repos/springernature/bandiera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/springernature/bandiera/merges","archive_url":"https://api.github.com/repos/springernature/bandiera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/springernature/bandiera/downloads","issues_url":"https://api.github.com/repos/springernature/bandiera/issues{/number}","pulls_url":"https://api.github.com/repos/springernature/bandiera/pulls{/number}","milestones_url":"https://api.github.com/repos/springernature/bandiera/milestones{/number}","notifications_url":"https://api.github.com/repos/springernature/bandiera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/springernature/bandiera/labels{/name}","releases_url":"https://api.github.com/repos/springernature/bandiera/releases{/id}","deployments_url":"https://api.github.com/repos/springernature/bandiera/deployments","created_at":"2013-11-14T15:24:04Z","updated_at":"2017-06-28T10:58:06Z","pushed_at":"2017-09-16T12:08:59Z","git_url":"git://github.com/springernature/bandiera.git","ssh_url":"git@github.com:springernature/bandiera.git","clone_url":"https://github.com/springernature/bandiera.git","svn_url":"https://github.com/springernature/bandiera","homepage":null,"size":311,"stargazers_count":37,"watchers_count":37,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":13,"forks":13,"open_issues":13,"watchers":37,"default_branch":"master"}},"base":{"label":"springernature:master","ref":"master","sha":"05fcb8bb216daa30caed9ebde3cf5334fa6f9c2f","user":{"login":"springernature","id":13002186,"avatar_url":"https://avatars2.githubusercontent.com/u/13002186?v=4","gravatar_id":"","url":"https://api.github.com/users/springernature","html_url":"https://github.com/springernature","followers_url":"https://api.github.com/users/springernature/followers","following_url":"https://api.github.com/users/springernature/following{/other_user}","gists_url":"https://api.github.com/users/springernature/gists{/gist_id}","starred_url":"https://api.github.com/users/springernature/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/springernature/subscriptions","organizations_url":"https://api.github.com/users/springernature/orgs","repos_url":"https://api.github.com/users/springernature/repos","events_url":"https://api.github.com/users/springernature/events{/privacy}","received_events_url":"https://api.github.com/users/springernature/received_events","type":"Organization","site_admin":false},"repo":{"id":14398758,"name":"bandiera","full_name":"springernature/bandiera","owner":{"login":"springernature","id":13002186,"avatar_url":"https://avatars2.githubusercontent.com/u/13002186?v=4","gravatar_id":"","url":"https://api.github.com/users/springernature","html_url":"https://github.com/springernature","followers_url":"https://api.github.com/users/springernature/followers","following_url":"https://api.github.com/users/springernature/following{/other_user}","gists_url":"https://api.github.com/users/springernature/gists{/gist_id}","starred_url":"https://api.github.com/users/springernature/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/springernature/subscriptions","organizations_url":"https://api.github.com/users/springernature/orgs","repos_url":"https://api.github.com/users/springernature/repos","events_url":"https://api.github.com/users/springernature/events{/privacy}","received_events_url":"https://api.github.com/users/springernature/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/springernature/bandiera","description":"Simple Feature Flagging","fork":false,"url":"https://api.github.com/repos/springernature/bandiera","forks_url":"https://api.github.com/repos/springernature/bandiera/forks","keys_url":"https://api.github.com/repos/springernature/bandiera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/springernature/bandiera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/springernature/bandiera/teams","hooks_url":"https://api.github.com/repos/springernature/bandiera/hooks","issue_events_url":"https://api.github.com/repos/springernature/bandiera/issues/events{/number}","events_url":"https://api.github.com/repos/springernature/bandiera/events","assignees_url":"https://api.github.com/repos/springernature/bandiera/assignees{/user}","branches_url":"https://api.github.com/repos/springernature/bandiera/branches{/branch}","tags_url":"https://api.github.com/repos/springernature/bandiera/tags","blobs_url":"https://api.github.com/repos/springernature/bandiera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/springernature/bandiera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/springernature/bandiera/git/refs{/sha}","trees_url":"https://api.github.com/repos/springernature/bandiera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/springernature/bandiera/statuses/{sha}","languages_url":"https://api.github.com/repos/springernature/bandiera/languages","stargazers_url":"https://api.github.com/repos/springernature/bandiera/stargazers","contributors_url":"https://api.github.com/repos/springernature/bandiera/contributors","subscribers_url":"https://api.github.com/repos/springernature/bandiera/subscribers","subscription_url":"https://api.github.com/repos/springernature/bandiera/subscription","commits_url":"https://api.github.com/repos/springernature/bandiera/commits{/sha}","git_commits_url":"https://api.github.com/repos/springernature/bandiera/git/commits{/sha}","comments_url":"https://api.github.com/repos/springernature/bandiera/comments{/number}","issue_comment_url":"https://api.github.com/repos/springernature/bandiera/issues/comments{/number}","contents_url":"https://api.github.com/repos/springernature/bandiera/contents/{+path}","compare_url":"https://api.github.com/repos/springernature/bandiera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/springernature/bandiera/merges","archive_url":"https://api.github.com/repos/springernature/bandiera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/springernature/bandiera/downloads","issues_url":"https://api.github.com/repos/springernature/bandiera/issues{/number}","pulls_url":"https://api.github.com/repos/springernature/bandiera/pulls{/number}","milestones_url":"https://api.github.com/repos/springernature/bandiera/milestones{/number}","notifications_url":"https://api.github.com/repos/springernature/bandiera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/springernature/bandiera/labels{/name}","releases_url":"https://api.github.com/repos/springernature/bandiera/releases{/id}","deployments_url":"https://api.github.com/repos/springernature/bandiera/deployments","created_at":"2013-11-14T15:24:04Z","updated_at":"2017-06-28T10:58:06Z","pushed_at":"2017-09-16T12:08:59Z","git_url":"git://github.com/springernature/bandiera.git","ssh_url":"git@github.com:springernature/bandiera.git","clone_url":"https://github.com/springernature/bandiera.git","svn_url":"https://github.com/springernature/bandiera","homepage":null,"size":311,"stargazers_count":37,"watchers_count":37,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":13,"forks":13,"open_issues":13,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/springernature/bandiera/pulls/80"},"html":{"href":"https://github.com/springernature/bandiera/pull/80"},"issue":{"href":"https://api.github.com/repos/springernature/bandiera/issues/80"},"comments":{"href":"https://api.github.com/repos/springernature/bandiera/issues/80/comments"},"review_comments":{"href":"https://api.github.com/repos/springernature/bandiera/pulls/80/comments"},"review_comment":{"href":"https://api.github.com/repos/springernature/bandiera/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/springernature/bandiera/pulls/80/commits"},"statuses":{"href":"https://api.github.com/repos/springernature/bandiera/statuses/045f1f3086bc189d50910ca6be015e4612f37335"}},"author_association":"NONE"}}
{"actor":{"display_login":"jshiell"}}