-
Notifications
You must be signed in to change notification settings - Fork 1
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
Community Questions #1
Comments
Should Increment / Decrement be part of the SimpleCache spec? |
Should Multi Get / Set / Delete be part of the SimpleCache spec? |
Should the exists() method be part of the SimpleCache spec? |
To all those voting no, I do wonder why? Those are all pretty trivial to implement for cache implementors, and they do provide substantial value in terms of performance (multi*) and just outright being able to implement things that would not be possible otherwise (incr/decr). Not having them sucks in some cases, and adding them is cheap on the implementation side and can only benefit on the user side, so why not have them? |
@Seldaek, because atomic inc/dec can be problematic for drivers, what then? Use non-atomic operation or fail? That’s not a simple interface anymore (IMO). |
@mlebkowski IMO if you use a driver that doesn't implement these, then you don't have an application load in which the atomicity matters anyway, so if the driver lies and isn't atomic it's probably not a huge deal. If you have any kind of real concurrency needs you really want to use memcache or redis, not some half-baked filesystem implementation. The point is the interface defines it as atomic and users should assume it is, if you then configure a driver that isn't following the interface strictly that's your problem. |
@Seldaek, I think you should add this comment to the spec and it would clear things out. If it would be described as "preferably atomic but with a fallback allowed" operations then sure — there is no cost in implementing them as |
No, because it has nothing nothing to do with a) a cache system in general an b) with a SimpleCache version. Cache is about to avoid re-computation in a temp storage. inc/decs makes the storage non-temp anymore and has nothing in common with the idea of jump over re-computation.
No, because this is nothing people use mostly. Thus, it shouldn't be included in the "Simple" cache.
No, because it leads to race-conditions. |
@marcj as for exists() - it's documented when to/not to use this method. https://github.com/dragoonis/fig-standards/blob/psr-simplecache/proposed/simplecache.md |
@dragoonis ah, seems legit :) |
No, not really. What could be done is an interface extending it providing locking and fundamental atomic primitives. It's outside the scope of simple cache. Most simple caching (i.e. store a compiled template. Prevent recalculating of something based on a static dataset), does not need that. (At the very least, if you have atomic functions, you also should have locking IMO.)
As separate methods, not so much, but you might make the simple get/set functions allow to also be passed arrays and Traversables.
No; this has the advantage of being able to have This leads us to use null as value for inexistence. Sure, you may want to allow negative caching; but in this case the user can just use a placeholder like an empty array (or whatever fits in the specific case). |
@dragoonis If exists() is meant for cache warming, why can't we just check against get() returning null? |
Btw, related long discussion in PHP-CDS: initial php-cds/php-cds#7 and further discussion in php-cds/php-cds-discussion#4 |
The comments around Increment / Decrement have been listened to and the compromise is that a |
@dragoonis I still think the separate interface shall then offer complete functionality including locks etc. It's rare that you only need counting. |
@bwoebi exists() isn't the same as get() !== null. You have to transfer the payload over the network from server->client, and then unserialize() the payload into PHP objects, consuming CPU and MEM overhead too, just to look inside a box and see if something is there? This is why all popular caching libraries (Zend / Doctrine) and all the caching drivers (apc,memcached,redis..etc) ship with exists(). It doesn't deserve its own Interface and will be part of the CacheInterface. |
@dragoonis Typically, you only initialize something you need in the current request. You anyway have to fetch the data over the network in these cases. It is pretty much an edge case where you don't need it. I'm not even aware of any cases (apart from non-real world made up cases) where it isn't the case that you initialize something you don't need in that same request. |
I voted yes on multi, but no on inc/dec. I'm not sure inc/dec belongs in a SimpleCache implementation. Simple should just be get, set, exists, and maybe delete (could be done with setting no value). |
No description provided.
The text was updated successfully, but these errors were encountered: