Repository navigation
Cache stores different values on the same key depending on expansion #269
Copy link
Copy link
Open
Description
The cache stores different values on the same key when the expand is different.
For example,
acc = Account(client, 'https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO')
acc
this stores the following value on the key https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO:
{
"created_at": "2016-06-23 00:43:33.144625",
"value": {
"modifiedAt": "2016-06-20T00:39:03.990Z",
"givenName": "A",
"providerData": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/providerData"},
"customData": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/customData"},
"createdAt": "2016-01-18T03:52:41.033Z",
"groups": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/groups"},
"apiKeys": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/apiKeys"},
"directory": {"href": "https://api.stormpath.com/v1/directories/5NG7dthzR1Jxip14J2hoZt"},
"emailVerificationToken": null,
"fullName": "A H",
"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO",
"surname": "H",
"middleName": null,
"username": "email@example.com",
"passwordModifiedAt": "2016-06-20T00:39:03.000Z",
"groupMemberships": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/groupMemberships"},
"accessTokens": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/accessTokens"},
"sp_http_status": 200,
"email": "email@example.com",
"status": "ENABLED",
"tenant": {"href": "https://api.stormpath.com/v1/tenants/6l2Vdm2FcmmVKnLK6JYqI7"},
"applications": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/applications"},
"refreshTokens": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/refreshTokens"}
},
"last_accessed_at": "2016-06-23 00:43:33.144625"
}
However, if Group is expanded like this,
acc = Account(client, 'https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO', expand=Expansion('groups'))
acc
the stored values becomes the following:
{
"created_at": "2016-06-23 00:51:45.203687",
"value": {
"modifiedAt": "2016-06-20T00:39:03.990Z",
"givenName": "A",
"providerData": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/providerData"},
"customData": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/customData"},
"createdAt": "2016-01-18T03:52:41.033Z",
"groups": {
"items": [{
"href": "https://api.stormpath.com/v1/groups/2CVGfGwO6ExuQtthnkfXCb"
}, {
"href": "https://api.stormpath.com/v1/groups/Ykct8r165JBGu0dQuZkyX"
}],
"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/groups"
},
"apiKeys": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/apiKeys"},
"directory": {"href": "https://api.stormpath.com/v1/directories/5NG7dthzR1Jxip14J2hoZt"},
"emailVerificationToken": null,
"fullName": "A H",
"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO",
"surname": "H",
"middleName": null,
"username": "email@example.com",
"passwordModifiedAt": "2016-06-20T00:39:03.000Z",
"groupMemberships": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/groupMemberships"},
"accessTokens": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/accessTokens"},
"sp_http_status": 200,
"email": "email@example.com",
"status": "ENABLED",
"tenant": {"href": "https://api.stormpath.com/v1/tenants/6l2Vdm2FcmmVKnLK6JYqI7"},
"applications": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/applications"},
"refreshTokens": {"href": "https://api.stormpath.com/v1/accounts/7BiLiECNu9auXe3i9mYenO/refreshTokens"}
},
"last_accessed_at": "2016-06-23 00:51:45.203687"
}
While the key is the same, the value is different.
The biggest problem of this behavior is that once a value is stored on the key, it won't be changed until the cache expires. So if the stored value is an object without expansion and we want to get an expanded one, we always get the one without expansion from the cache, until the cache expires. Therefore the cached value decreases efficiency.
Metadata
Metadata
Assignees
Labels
No labels
Activity
rdegges commentedon Jan 10, 2017
Hey @dinkom can you check out the SDK internals to see whether we are actually caching any URLs that contain querystrings?