Exemplo n.º 1
0
        //11.Gets test
        public void GetsTest()
        {
            MemcachedClient cache  = MemcachedClient.GetInstance("BeITMemcached");
            ulong           unique = 0;

            cache.Gets("liyanze", out unique);
            HandleLogs("[Cmd=Gets]Getting cas unique for key liyanze:" + unique.ToString());
        }
Exemplo n.º 2
0
        //16.Gets,同时获取多个key的unique
        public void GetsMutipleKeys()
        {
            //Get several values at once
            MemcachedClient cache = MemcachedClient.GetInstance("BeITMemcached");

            ulong[] unique = new ulong[2] {
                0, 0
            };
            object[] result = cache.Gets(new string[] { "myinteger", "BeIt" }, out unique);
            HandleLogs("[Cmd=Gets] GetsMutipleKeys myinteger unique:" + unique[0].ToString() + ",+ BeIt unique:" + unique[1].ToString());
        }
Exemplo n.º 3
0
        private ulong GetIncreasedIndex(string index_key)
        {
            ulong?index = null;

            while (index == null)
            {
                bool r = m_Client.Add(index_key, 0);
                if (r)
                {
                    index = 0;
                }
                else
                {
                    //index = m_Client.Increment(en_index_key, 1);
                    MemcachedClient.CasResult casRst;
                    ulong unique;
                    do
                    {
                        object t = m_Client.Gets(index_key, out unique);
                        if (t == null)
                        {
                            index = null;
                            break;
                        }
                        index = Convert.ToUInt64(t);
                        if (index >= MAX_LENGTH)
                        {
                            index = 0;
                        }
                        else
                        {
                            index = index + 1;
                        }
                        casRst = m_Client.CheckAndSet(index_key, index.Value, unique);
                    } while (casRst != MemcachedClient.CasResult.Stored);
                }
            }
            return(index.Value);
        }
Exemplo n.º 4
0
 public static Dictionary <string, string> Gets(string poolName, ref Dictionary <string, long> cass, params string[] keys)
 {
     try
     {
         MemcachedClient mc = MemcacheItem.GetInstance(poolName);
         mc.EnableCompression = false;
         mc.PoolName          = poolName;
         return(mc.Gets(keys, ref cass));
     }
     catch (Exception ex)
     {
         LogEngine.Write(LOGTYPE.ERROR, "MemcacheItem Gets ex:", ex.ToString());
         return(null);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 获取缓存并传出版本号
 /// </summary>
 /// <param name="strKey">缓存键</param>
 /// <param name="ulongNique">版本号</param>
 /// <returns></returns>
 public static object Gets(string strKey, out ulong ulongNique)
 {
     return(cache.Gets(strKey, out ulongNique));
 }