I am using the KeyExists function. It does work most of the time. But I noticed sometimes, that it does return true, although there is no item in the cache.
I am trying to see if the item already exists in the cache or not.
I did not want to use the Get operation.
I have read that we can use Touch operation. Not sure, if it return a bool value, or if it throws an exception, if not found.
Any suggesstions on which operation to use to check if the item exists in cache or not.
July 26, 2013, 3:23pm
Based on the document the client.touch() operation returns a boolean that is true if the key exists.
btw: I am surprised by the fact that the keyexists function does not return the correct status, this methods is based on the Observe method, as you can see that should return false of the key is not present:
return ExecuteRemove(key, PersistTo.Zero, replicateTo);
public bool KeyExists(string key)
return KeyExists(key, 0);
public bool KeyExists(string key, ulong cas)
var result = Observe(key, cas, PersistTo.Zero, ReplicateTo.Zero);
public IObserveOperationResult Observe(string key, ulong cas, PersistTo persistTo, ReplicateTo replicateTo,
ObserveKeyState persistedKeyState = ObserveKeyState.FoundPersisted,
ObserveKeyState replicatedState = ObserveKeyState.FoundNotPersisted)
var hashedKey = this.KeyTransformer.Transform(key);
var vbucket = this.poolInstance.GetVBucket(key);
var nodes = this.poolInstance.GetWorkingNodes().ToArray();