Feature #25262
closedadd() method needed in caching framework
0%
Description
Would be good to implement add() method in caching framework. Such method exists in memcached yet and I think could be implemented in DB backend too.
In memcached add() method stores variable with key only if such key doesn't exist yet. add() returns FALSE if such key already exist.
This is vital for correct implementation of locking in cache - first client who acquire lock sets NULL by key in cache and next clients will wait until data is ready and NULL replaced with data. add() method is needed to make sure that only one client will acquire the lock. If add($key, NULL) returns FALSE then lock acquired yet.
I know that there is locking API in TYPO3, but IMHO locks being implemented directly in cache is better for the sake of caching - in such case we just read the cache for data and at once see if lock is set and no other API calls are needed.
Also in case of memcached it should work much faster than file based locking.
(issue imported from #M17874)
Updated by Christian Kuhn about 13 years ago
- Status changed from New to Rejected
- Target version changed from 0 to 1281
- TYPO3 Version changed from 4.5 to 4.6
This will not be implemented: Locking is not scope of the caching framework, a cache entry should be overwritten if set() is called for the same identifier.
For locking t3lib_lock should be used which can already handle different locking methods.
Updated by Vladimir Podkovanov almost 13 years ago
Christian Kuhn wrote:
Locking is not scope of the caching framework
but finding out if cache entry exists yet is in the scope of the caching framework
a cache entry should be overwritten if set() is called for the same identifier.
I proposed to implement add() method (which exists in memcached but can't be accessed via TYPO3 API), I did not mention set() method
add() method needed not only for locking it was just an example what many high load applications use it to determine if cache entry exists yet.
It is simple and works much faster than to use some additional locks for it.