{"action":"created","issue":{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/476","repository_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node","labels_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/476/labels{/name}","comments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/476/comments","events_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/476/events","html_url":"https://github.com/stormpath/stormpath-sdk-node/issues/476","id":159709714,"number":476,"title":"Cache misses on non-trivial URL structures","user":{"login":"4storia","id":4867895,"avatar_url":"https://avatars.githubusercontent.com/u/4867895?v=3","gravatar_id":"","url":"https://api.github.com/users/4storia","html_url":"https://github.com/4storia","followers_url":"https://api.github.com/users/4storia/followers","following_url":"https://api.github.com/users/4storia/following{/other_user}","gists_url":"https://api.github.com/users/4storia/gists{/gist_id}","starred_url":"https://api.github.com/users/4storia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4storia/subscriptions","organizations_url":"https://api.github.com/users/4storia/orgs","repos_url":"https://api.github.com/users/4storia/repos","events_url":"https://api.github.com/users/4storia/events{/privacy}","received_events_url":"https://api.github.com/users/4storia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-06-10T19:52:13Z","updated_at":"2016-06-24T14:46:51Z","closed_at":null,"body":"https://github.com/stormpath/stormpath-sdk-node/blob/master/lib/cache/CacheHandler.js#L79\r\n\r\n^ Cache entry lookup does a split on the resource href to determine which cache region to perform get/put against. Unfortunately, if I make a request for something more complicated than a region, such as an account's associated groups, this splits against `https://api.stormpath.com/v1/accounts/<accId>/groups`, which results in the cache region being `<accId>`, rather than `accounts`. In essence, because this is not a valid cache region, no cache entry is ever created for this request, meaning every request for an account's groups results in an API call.\r\n\r\nAs a rudimentary tweak, I would change this logic to from `href.split('/').slice(-2)[0]` to `href.split('/').slice(4)[0]`, but I'm obviously not intimately familiar with this code, so there may be a reason the code wasn't written that way.\r\n\r\nIn any event, what I'm really after is a way to cache a user account AND that user's corresponding groups. Because requesting accounts via `client.getAccount(href, { expand: 'groups' })` results in the cache being skipped entirely, I figured I would just make two separate API calls and then combine the results. Group memberships change very infrequently in my application, so it makes a lot more sense to cache these values than to request them fresh every time I need them."},"comment":{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/comments/228365924","html_url":"https://github.com/stormpath/stormpath-sdk-node/issues/476#issuecomment-228365924","issue_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/476","id":228365924,"user":{"login":"4storia","id":4867895,"avatar_url":"https://avatars.githubusercontent.com/u/4867895?v=3","gravatar_id":"","url":"https://api.github.com/users/4storia","html_url":"https://github.com/4storia","followers_url":"https://api.github.com/users/4storia/followers","following_url":"https://api.github.com/users/4storia/following{/other_user}","gists_url":"https://api.github.com/users/4storia/gists{/gist_id}","starred_url":"https://api.github.com/users/4storia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4storia/subscriptions","organizations_url":"https://api.github.com/users/4storia/orgs","repos_url":"https://api.github.com/users/4storia/repos","events_url":"https://api.github.com/users/4storia/events{/privacy}","received_events_url":"https://api.github.com/users/4storia/received_events","type":"User","site_admin":false},"created_at":"2016-06-24T14:46:51Z","updated_at":"2016-06-24T14:46:51Z","body":"that was real weird, I lost all of your comments + all of the issues you've created. Not really sure what happened there...."}}
{"actor":{"display_login":"4storia"}}