-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SimpleCacheDecorator and providesPerItemTtl leads undocumented behaviors #5
Comments
I just ran into this and it took a surprising amount of head scratching before I realised the per item TTL was to blame. Commenting mostly so I can keep track of this issue. Originally posted by @Zegnat at zendframework/zend-cache#171 (comment) |
@dol @Zegnat It might be fixed in #184 and released yday - can you please check version 2.8.3 and tell me if you still observe the issue? Thanks! Originally posted by @michalbundyra at zendframework/zend-cache#171 (comment) |
PSR-16
I have the feeling that what PSR-16 defines here could be very very dangerous: function verifyAccessToken($accessToken) {
$accessTokenValidKey = 'access_token_valid_' . md5($accessToken);
if ($cache->get($accessTokenValidKey) !== '1') {
// verify access token by querying authentication server
// if invalid -> return false
// if valid -> authentication server returns expiration ($expiresIn)
$cache->set($accessTokenValidKey, '1', $expiresIn);
}
return true;
} The Time-to-Live should define the maximum time where this item is considered valid. In caching it normally means that there is a guaranty to be invalidated after that time and this guaranty gets lost here. Originally posted by @marc-mabe at zendframework/zend-cache#171 (comment) |
Closing this as there were no author updates since 06/2018. |
@dol If this is still a thing, feel free ping me here so I can re-open the issue. |
@boesing Will do. Thank you. Switched programming language and company in the meantime. I leave it here for my former team members. |
The SimpleCacheDecorator returns
false
and doesn't store the item if the underlying storage doesn't has thestaticTtl
capability.For testing purposes I changed from an APCU storage to memory storage. Our tests where failing due to the fact that the memory storage has no per item ttl support => in other words
staticTtl = false
. https://github.com/zendframework/zend-cache/blob/580cb67bf645c1765c3463b16c97903d797c3b19/src/Psr/SimpleCache/SimpleCacheDecorator.php#L360In our code base we where not checking the return value of CacheInterface::set(), which in the case of
memory
return false.The documentation has no information about this behavior:
In our case we set a TTL on the adapter level. But we also set the TTL per item to make sure the item has the same TTL even when we replace the underlying PSR-16 library.
Our workaround for the moment is to set the per item TTL to
null
for an Zend cache adapter that doesn't support staticTtl. This adds some unwanted conditional if/else and knowledge about the special behavior. There is also the problem if the internal detection state ofprovidesPerItemTtl
changes in never releases we need to adopt to this changes.Possible solution (eater one of them or a combination)##
Originally posted by @dol at zendframework/zend-cache#171
The text was updated successfully, but these errors were encountered: