"Iteratable" keys in memcache?

Christopher Gillett cgillett at compete.com
Tue Aug 2 08:18:27 PDT 2005

I'm building an application that needs to run quickly.  My plan is to
use memcache to store state data...since the state data can be recreated
if needed, and since the application needs to run quickly, I am planning
on not using a database as a backing store.  I'm looking for some way to
create unique keys that I can use to iterate over the cache entries -
much like a row number or an auto-increment id in a database.  Is there
any functionality in memcache or elsewhere that I can use to create
guarenteed unique keys that of an iteratable form?  I don't see global
or cache-entry specific lock()/unlock() in memcache, so I'm wondering if
there's a way to solve this within memcache.

There will be many resources trying to create cache entries while my
application is active, so I'm looking for  sort of guarenteed atomic
operation.  Something like:

		value = cache.get("the next row id")
		value +=1
		cache.set("the next row id", value)

won't work because another running instance could produce the same value
at the same time.

If there's no support for something like this, is there any interest in
an "atomic increment" function for memcache?  I'd be willing to dig into
it if there is a broader need.

Any thoughts?


Christopher Gillett
Compete, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20050802/e0f96a96/attachment.html

More information about the memcached mailing list