Ejemplo n.º 1
0
        public static bool Prepend(string poolName, string key, string value, int liveSecs = UnExpired, bool compress = false)
        {
            try
            {
                if (liveSecs < 0)
                {
                    return(false);
                }

                if (liveSecs == 0)
                {
                    liveSecs = UnExpired;
                }

                DateTime        expired = DateTime.Now.AddSeconds(liveSecs);
                MemcachedClient mc      = MemcacheItem.GetInstance(poolName);
                mc.PoolName          = poolName;
                mc.EnableCompression = compress;

                return(mc.Prepend(key, value, expired));
            }
            catch (Exception ex)
            {
                LogEngine.Write(LOGTYPE.ERROR, "MemcacheItem Prepend ex:", ex.ToString());
                return(false);
            }
        }
Ejemplo n.º 2
0
 public static bool DeleteAferExpire(string poolName, string key, int expireSecs)
 {
     try
     {
         MemcachedClient mc = MemcacheItem.GetInstance(poolName);
         mc.PoolName = poolName;
         return(mc.Delete(key, DateTime.Now.AddSeconds(expireSecs)));
     }
     catch (Exception ex)
     {
         LogEngine.Write(LOGTYPE.ERROR, "MemcacheItem DeleteAferExpire ex:", ex.ToString());
         return(false);
     }
 }
Ejemplo n.º 3
0
 public static bool Delete(string poolName, string key)
 {
     try
     {
         MemcachedClient mc = MemcacheItem.GetInstance(poolName);
         mc.PoolName = poolName;
         return(mc.Delete(key));
     }
     catch (Exception ex)
     {
         LogEngine.Write(LOGTYPE.ERROR, "MemcacheItem Delete ex:", ex.ToString());
         return(false);
     }
 }
Ejemplo n.º 4
0
 public static Dictionary <string, string> Gets_Ext(ref int error, ref string errorDetail,
                                                    string poolName, ref Dictionary <string, long> cas, params string[] keys)
 {
     try
     {
         MemcachedClient mc = MemcacheItem.GetInstance(poolName);
         mc.EnableCompression = false;
         mc.PoolName          = poolName;
         return(mc.Gets_Ext(keys, null, ref cas, ref error, ref errorDetail));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 5
0
 public static Dictionary <string, byte[]> Gets_Bytes(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_Bytes(keys, ref cass));
     }
     catch (Exception ex)
     {
         LogEngine.Write(LOGTYPE.ERROR, "MemcacheItem Gets_Bytes ex:", ex.ToString());
         return(null);
     }
 }
Ejemplo n.º 6
0
 public static byte[] Get_Bytes(string poolName, string key, bool compress = false)
 {
     try
     {
         MemcachedClient mc = MemcacheItem.GetInstance(poolName);
         mc.EnableCompression = compress;
         mc.PoolName          = poolName;
         return(mc.Get_Bytes(key));
     }
     catch (Exception ex)
     {
         LogEngine.Write(LOGTYPE.ERROR, "MemcacheItem Get_Bytes ex:", ex.ToString());
         return(null);
     }
 }