Membase Client - ContainsKey? -


does know how check if key exists using membase client (enyim)? dont want pull entire object cache, check if in there.

unfortunately there no "exists" operation in memcached, there hacks can do:

  • do client.store(storemode.add, keytocheck, null, new date(2000, 1, 1)); add fails if item exists, , return false in case.
  • you can client.append(keytocheck, new arraysegment<byte>(new byte[0])) return true if key exists, value not change.
  • or client.cas(storemode.set, keytocheck, null, uint64.maxvalue) fail if item exists.

please keep in mind 3 operations will create item if key not exist, need clean after them.

also, if multiple threads checking same item, it's possible 1 thread treat threads temp item real one.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -