Memcached Cas Method Support, Anyone?

Hi,

So I’ve searched and searched and nothing. Can’t believe no one has really needed and used the powerful and comfortable “check and set” method of memcached before me. [size=2]I think that [/size][size=2]cas() is, in short, like ‘SELECT… FOR UPDATE’ in MySQL and allows atomicity of the get and then set methods, effectively ensuring that only one client handles the updating of some cached value (given that they all use the same pattern of get(), storing the token, then cas() passing that token).[/size]

The ‘cas()’ was introduced in the memcached php extension, which is newer than memcache. See this Stackoverflow discussion about the comparison.

Now for our matter: there is no ‘cas()’ method support in CMemCache class. Further more, but this is hardly the focus here, by default CMemCache uses the old (more mature?..) and AFAIK less powerful memcache php extension, instead of memcached extension (which includes this cas() support, and more).

[size=2]Having cas() support in Yii can be very very nice. memcache daemon is a cool, old no SQL caching program that can be used extensively for improving performance. [/size]

Anyone tackled this and can share his/her solution?

Any plans for the future with regard to the mentioned php extensions and their capabilities?

TIA,

Boaz.

CMemCache can use both memcache and memcached. We don’t have atomicity exposed via cache API since most of backends aren’t able to implement it.

I see. Sure, cas() etc is memcached specific feature. In other words - there’s more than get() and set() in memcached… .

[size=2]Shortly after [/size]writing this post I’ve written a class for memcached implementation which support using cas() with the relevant token (which affects ‘get()’ as well, as a result). Its already written as an extension - I just need to test it now with some data I need to prepare, which depends on other not-yet-written code so this will little a little more time to complete.

Thanks.