{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/24259780","id":24259780,"diff_hunk":"@@ -76,6 +81,57 @@ func (c *cache) Add(obj interface{}) error {\n \tc.lock.Lock()\n \tdefer c.lock.Unlock()\n \tc.items[key] = obj\n+\tc.updateIndices(obj)","path":"pkg/client/cache/store.go","position":23,"original_position":23,"commit_id":"b0d388e652f02bdbae5b02ad43910eb7f5607a64","original_commit_id":"b0d388e652f02bdbae5b02ad43910eb7f5607a64","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"You might have to hold *a* lock while doing that (or the Add has to fail fast if there's a conflict and you have to try again)\n\n----- Original Message -----\n> > @@ -76,6 +81,57 @@ func (c *cache) Add(obj interface{}) error {\n> >  \tc.lock.Lock()\n> >  \tdefer c.lock.Unlock()\n> >  \tc.items[key] = obj\n> > +\tc.updateIndices(obj)\n> \n> so if on update, i get the previous object based on its key, and then remove\n> that object from all indices, then for updated object treat like an add, it\n> should be fine.  will make an update this afternoon.\n> \n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/GoogleCloudPlatform/kubernetes/pull/4125/files#r24257444\n","created_at":"2015-02-06T18:20:03Z","updated_at":"2015-02-06T18:20:03Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4125#discussion_r24259780","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4125","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/24259780"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4125#discussion_r24259780"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4125"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4125","id":28673869,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4125","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4125.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4125.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/4125","number":4125,"state":"open","locked":false,"title":"Enable look-up by secondary index in cache","user":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"body":"This is an enhancement to our cache to let you optionally create a store that can build a secondary index on its data.  The main use case is I want to have a store that holds a bunch of resources across namespaces, and I want to be able to then interface with that store by asking to retrieve only the resources in namespace X.\r\n\r\nIf folks are good with this pattern, I will adopt it in the admission control handlers for resource quota and limit range.\r\n\r\n@smarterclayton @ironcladlou @erictune ","created_at":"2015-02-04T20:52:12Z","updated_at":"2015-02-06T18:20:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9d8dda3045ba5c89817284a6599b3d8741bacb6","assignee":{"login":"dchen1107","id":7740897,"avatar_url":"https://avatars.githubusercontent.com/u/7740897?v=3","gravatar_id":"","url":"https://api.github.com/users/dchen1107","html_url":"https://github.com/dchen1107","followers_url":"https://api.github.com/users/dchen1107/followers","following_url":"https://api.github.com/users/dchen1107/following{/other_user}","gists_url":"https://api.github.com/users/dchen1107/gists{/gist_id}","starred_url":"https://api.github.com/users/dchen1107/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchen1107/subscriptions","organizations_url":"https://api.github.com/users/dchen1107/orgs","repos_url":"https://api.github.com/users/dchen1107/repos","events_url":"https://api.github.com/users/dchen1107/events{/privacy}","received_events_url":"https://api.github.com/users/dchen1107/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4125/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4125/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/{number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/4125/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/b0d388e652f02bdbae5b02ad43910eb7f5607a64","head":{"label":"derekwaynecarr:store_by_namespace","ref":"store_by_namespace","sha":"b0d388e652f02bdbae5b02ad43910eb7f5607a64","user":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"repo":{"id":21397341,"name":"kubernetes","full_name":"derekwaynecarr/kubernetes","owner":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/derekwaynecarr/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/derekwaynecarr/kubernetes","forks_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/forks","keys_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/teams","hooks_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/events","assignees_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/tags","blobs_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/languages","stargazers_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/subscription","commits_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/issues/comments/{number}","contents_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/merges","archive_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/downloads","issues_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/derekwaynecarr/kubernetes/releases{/id}","created_at":"2014-07-01T17:56:58Z","updated_at":"2014-07-01T18:46:05Z","pushed_at":"2015-02-06T03:43:42Z","git_url":"git://github.com/derekwaynecarr/kubernetes.git","ssh_url":"git@github.com:derekwaynecarr/kubernetes.git","clone_url":"https://github.com/derekwaynecarr/kubernetes.git","svn_url":"https://github.com/derekwaynecarr/kubernetes","homepage":null,"size":29850,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"f904484b3852b4a77108283471de52bb3b23472a","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"GoogleCloudPlatform/kubernetes","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes","description":"Container Cluster Manager","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments/{number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-02-06T17:58:52Z","pushed_at":"2015-02-06T17:58:52Z","git_url":"git://github.com/GoogleCloudPlatform/kubernetes.git","ssh_url":"git@github.com:GoogleCloudPlatform/kubernetes.git","clone_url":"https://github.com/GoogleCloudPlatform/kubernetes.git","svn_url":"https://github.com/GoogleCloudPlatform/kubernetes","homepage":"http://kubernetes.io","size":71242,"stargazers_count":6106,"watchers_count":6106,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1043,"mirror_url":null,"open_issues_count":660,"forks":1043,"open_issues":660,"watchers":6106,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4125"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4125"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/4125"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/4125/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4125/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4125/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/b0d388e652f02bdbae5b02ad43910eb7f5607a64"}}}}