-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feature/psr16 support #791
Conversation
/** | ||
* Wrap the PSR simple cache implementation into the legacy interface | ||
*/ | ||
class common_cache_PsrWrapperCache extends ConfigurableService implements common_cache_Cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not create new classes in legacy namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class provides the legacy interface and should be discouraged from being used, as is present for backward compatibility only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be discouraged from being used
In that case it has to be marked as deprecated.
As we are going to get rid of legacy autoloader it's better to not create new classes in the legacy namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduce in the PR a new deprecated class and then configure it to be used by default does not seem to me like a good practice!
How difficult will be to change it's usage to not catch common_cache_NotFoundException
? I found 14 catches of that exception in three extensions:
tao
taoAct
taoMpArt (that one can be omitted)
I could help with cleaning that up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed all references to old cache from generis, so that we can move quicker when it comes to cleaning up old references, but I still don't want to make this feature backward incompatible, even if we could fix all other known extensions quickly
{ | ||
$success = true; | ||
foreach ($values as $key => $value) { | ||
$success = $this->set($key, $value, $ttl) && $success; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may confuse developers. In case of failure all already set values have to be deleted.
The same for delete. All already deleted items have to be restored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find any indication in the PSR on how a partial success/failure should be handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case this behavior is up to implementation.
I think rolling back in that case corresponds to best practices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I have no idea how to implement this rollback as filesystems are not transactional
I don't like approach as it allows developers to use old cache interface. |
Unfortunately our legacy get() method is not compatible with the PSR interface, so having dual support would not be possible |
Signature of get() method is compatible:
Just add |
Our current implementation of get() throws an exception on cache miss, the PSR implementation returns the default value, so unfortunately this is not possible |
Throwing an exception when default value was not given does not seem like an interface violation. |
Looks good! |
Please fix phpdoc block ( |
I could fix the issues, but it is in code that is going to be deleted, so I did not bother. Are there incorecct tags in the part of the code that will not be deleted? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job, one step more to standardization. Could u create a task to remove this deprecated wrapper in order to close this topic ? :)
Support for SimpleCache implementations in the context of the cached functional access control