Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Elijaa.org:
Using cas() command from PECL Memcached
Oct 06, 2010 @ 14:16:44

On Elijaa.org there's an interesting post (from back in May 2010) about using the "cas()" command in the memcached PECL extension to update the cached value of an object while preventing collisions with other scripts that might be updating the same value.

A series of commands is not atomic. If you issue a 'get' against an item, operate on the data, then wish to 'set' it back into memcached, you are not guaranteed to be the only process working on that value. In parallel, you could end up overwriting a value set by something else. [...] But PECL Memcached come with a useful function : cas().

The "cas()" function uses a checksum pulled out when the data is uplled using "get()". This token along with the updated data is passed into the "cas()" method that does the additional checking for you. A code snippet is included to show you its use.

tagged: pecl memcached cas checksum tutorial

Link:

Ibuildings techPortal:
New Memcached Extension for PHP
Jun 22, 2009 @ 15:27:51

The Ibuildings techPortal website has posted a new article from Lorna Mitchell looking at the new and improved memcached extension (as most recently updated by Andrei Zmievski).

The idea behind the new extension is to leverage the functionality contained libmemcached - a solution which has been widely adopted across many scripting communities and beyond. The extension is available in PECL and has lots of shiny new functionality. This article looks at how to obtain and work with the new extension, and also shows off a couple of the new features it includes.

Lorna talks a bit about the features of the extension in general but mentions two great new ones specifically - the "getmulti" fetch method allows for grabbing multiple chunks of cached information and the cas (compare and swap) function that works the same as a replace but checks the current contents first.

tagged: cas getmultii extension memcached

Link:


Trending Topics: