> I'm thinking about implementing a PEEK command. It turns out that on > large payloads ( >= 1MB) it would be advantageous to know if the data > already exists before doing all the work to create the data. I would > like to solicited some feedback before I dive into it. > > - Is there already a way to check for the existence of a key before > fetching the data? If so, then I would like to know how to do so and > not waste my time. > > - I was thinking this would be more-or-less a clone of item_get() as > item_peek() except it returns 1 or 0 to the user instead of the > payload. > > Thoughts?
Just do a 0 byte add with an expiration time in the past. If the add succeeds, the item wasn't already there. For bonus points, you could add with a 5 second timeout, then use set to overwrite your key. So two processes would serialize on the add call. touch could probably be used as well.
