.net sdk 1.3.7 error Increment,Decrement

store a int value couchbase ,it’,s store with base64
client.Store(Enyim.Caching.Memcached.StoreMode.Set, allkey, 1);
next do Increment,Decrement value not change
client.Decrement(keyAll, 0, 1, TimeSpan.FromDays(1));
client.Increment(keyAll, 1, 1,TimeSpan.FromDays(1));

but if you not first use client.Store,direct use client.Increment

it’,s store with not base64 , it’,s
then get value, client.Get<int?>(key) or client.Get<ulong?>(key) with cast type error
you must use : client.Get(key) it’s bug??

In general when using Increment or Decrement it’s not suggested you use the Store method, but instead start with either Increment or Decrement. Here is some additional information:

"If you want to set the value of the counter with add/set/replace, the objects data must be the ascii representation of the value and not the byte values of a 64 bit integer. "

  • https://code.google.com/p/memcached/wiki/BinaryProtocolRevamped#Increment,_Decrement
  • http://docs.couchbase.com/couchbase-devguide-2.0/#incrementing-and-decrementing

The solution/answer is to always use increment/decrement operations when you want use a key for counting (which is a best practice).

-Jeff