<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7226.0">
<TITLE>"Iteratable" keys in memcache?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<BR>
<P><FONT SIZE=2 FACE="Arial">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.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">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:</FONT></P>
<P> <FONT SIZE=2 FACE="Arial">value = cache.get("the next row id")</FONT>
<BR> <FONT SIZE=2 FACE="Arial">value +=1</FONT>
<BR> <FONT SIZE=2 FACE="Arial">cache.set("the next row id", value)</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">won't work because another running instance could produce the same value at the same time.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">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.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Any thoughts?</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Thanks,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Chris</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">---</FONT>
<BR><FONT SIZE=2 FACE="Arial">Christopher Gillett</FONT>
<BR><FONT SIZE=2 FACE="Arial">Compete, Inc.</FONT>
</P>
</BODY>
</HTML>