Exemple #1
0
        public override void FlushAll()
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "FlushAll";
            PostData postdata = new PostData()
            {
                app = ""
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
#else
            throw new Exception("not support this method");
#endif
        }
Exemple #2
0
 /// <summary>
 /// 获取操作数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public UserLogViewModel <T> GetOprData <T>()
 {
     if (oprData != null)
     {
         try
         {
             return(CommonExtenstion.ToJson <UserLogViewModel <T> >(oprData));
         }
         catch
         {
             return(new UserLogViewModel <T>());
         }
     }
     else
     {
         return(new UserLogViewModel <T>());
     }
 }
Exemple #3
0
        public override bool Set <T>(string key, T value, DateTime time)
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "Set";
            PostSetData <T> postdata = new PostSetData <T>()
            {
                app = "", key = key, value = value, outtime = (int)(time.Timestamp() - DateTime.Now.Timestamp())
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
            if (rd.result.IndexOf("sussecc") >= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
#else
            throw new Exception("not support this method");
#endif
        }
Exemple #4
0
        /// <summary>
        /// 获取服务器信息
        /// </summary>
        /// <returns></returns>
        public override Dictionary <string, string> ServerInfo()
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "ServerInfo";
            PostData postdata = new PostData()
            {
                app = ""
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
            if (rd.result.IndexOf("sussecc") >= 0)
            {
                return(CommonExtenstion.ToJson <Dictionary <string, string> >(rd.data));
            }
            else
            {
                return(new Dictionary <string, string>());
            }
#else
            throw new Exception("not support this method");
#endif
        }
Exemple #5
0
        /// <summary>
        /// 获取key剩余生存时间,秒为单位
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public override long TTL(string key)
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "GetKeys";
            PostGetData postdata = new PostGetData()
            {
                app = "", key = key
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
            if (rd.result.IndexOf("sussecc") >= 0)
            {
                return(CommonExtenstion.ToJson <long>(rd.data));
            }
            else
            {
                return(-1);
            }
#else
            throw new Exception("not support this method");
#endif
        }
Exemple #6
0
        /// <summary>
        /// 获取存在的Key的值
        /// </summary>
        /// <param name="pattern">
        /// KEYS * 匹配数据库中所有 key 。
        /// KEYS h?llo 匹配 hello , hallo 和 hxllo 等。
        /// KEYS h*llo 匹配 hllo 和 heeeeello 等。
        /// KEYS h[ae]llo 匹配 hello 和 hallo ,但不匹配 hillo
        /// </param>
        /// <returns></returns>
        public override List <string> Keys(string pattern)
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "GetKeys";
            PostTryData postdata = new PostTryData()
            {
                app = "", pattern = pattern
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
            if (rd.result.IndexOf("sussecc") >= 0)
            {
                return(CommonExtenstion.ToJson <List <string> >(rd.data));
            }
            else
            {
                return(new List <string>());
            }
#else
            throw new Exception("not support this method");
#endif
        }
Exemple #7
0
        /// <summary>
        /// 设置生成时间
        /// </summary>
        /// <param name="key"></param>
        /// <param name="s"></param>
        /// <returns></returns>
        public override bool Expire(string key, int s)
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "SetOutTime";
            PostSetTimeData postdata = new PostSetTimeData()
            {
                app = "", key = key, outtime = s
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
            if (rd.result.IndexOf("sussecc") >= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
#else
            throw new Exception("not support this method");
#endif
        }
Exemple #8
0
        /// <summary>
        /// 根据key来删除缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public override long Delete(params string[] key)
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "Delete";
            PostDelData postdata = new PostDelData()
            {
                app = "", key = key
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
            if (rd.result.IndexOf("sussecc") >= 0)
            {
                return(Convert.ToInt64(rd.data));
            }
            else
            {
                return(0);
            }
#else
            throw new Exception("not support this method");
#endif
        }
Exemple #9
0
        /// <summary>
        /// 根据key获取缓存值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public override T Get <T>(string key)
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "Get";
            PostGetandTimeData postdata = new PostGetandTimeData()
            {
                app = "", key = key, delayouttime = "600"
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
            if (rd.result.IndexOf("sussecc") >= 0)
            {
                return(CommonExtenstion.ToJson <T>(rd.data));
            }
            else
            {
                return(default(T));
            }
#else
            throw new Exception("not support this method");
#endif
        }
Exemple #10
0
        /// <summary>
        /// 不带值则删除key对应的缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public override bool Set(string key)
        {
#if DNX451 || NET451
            var url = GetClient();
            url = url + "Delete";
            string[]    keys     = { key };
            PostDelData postdata = new PostDelData()
            {
                app = "", key = keys
            };
            var r  = Http.HttpPost(url, postdata.ToJson());
            var rd = CommonExtenstion.ToJson <ServerData>(r);
            if (rd.result.IndexOf("sussecc") >= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
#else
            throw new Exception("not support this method");
#endif
        }