Project

General

Profile

Actions

Feature #25262

closed

add() method needed in caching framework

Added by Vladimir Podkovanov over 13 years ago. Updated over 11 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Caching
Target version:
-
Start date:
2011-03-05
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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)

Actions #1

Updated by Christian Kuhn over 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.

Actions #2

Updated by Vladimir Podkovanov about 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.

Actions #3

Updated by Ernesto Baschny over 11 years ago

  • Target version deleted (1281)
Actions

Also available in: Atom PDF