//17.GetCounter 传递多个key值 public void GetCounterMutiplekeys() { //Get several values at once MemcachedClient cache = MemcachedClient.GetInstance("BeITMemcached"); cache.SetCounter("mycounter2", 365); ulong?[] result = cache.GetCounter(new string[] { "mycounter", "mycounter2" }); HandleLogs("[Cmd=Gets]GetCounterMutiplekeys mycounter:" + result[0].ToString() + ",+ mycounter2:" + result[1].ToString()); }
//10.GetCounter test public void GetCounterTest() { MemcachedClient cache = MemcachedClient.GetInstance("BeITMemcached"); cache.SetCounter("mycounter", 1213); ulong?counter = cache.GetCounter("mycounter"); if (counter.HasValue) { HandleLogs("[Cmd=GetCounter]mycounter:" + counter.Value.ToString()); } }
//4.SetCounter test public String SetCounterTest() { MemcachedClient cache = MemcachedClient.GetInstance("BeITMemcached"); cache.SetCounter("mycounter", 9000); ulong?counter = cache.GetCounter("mycounter"); if (counter.HasValue) { return(HandleLogs("[Cmd=SetCounter]mycounter:" + counter.Value.ToString())); } return(null); }
/// <summary> /// 设置计数器 /// </summary> /// <param name="key">键</param> /// <param name="value">值</param> public void SetCounter(string key, ulong value) { _mcClient.SetCounter(key, value); }
/// <summary> /// 设置缓存计数器 /// </summary> /// <param name="strKey">键</param> /// <param name="ulongCount">值</param> /// <returns></returns> public static bool SetCounter(string strKey, ulong ulongCount) { return(cache.SetCounter(strKey, ulongCount)); }