Пример #1
0
        public string[] GetPublicKey()
        {
            RSACrypto crypto = new RSACrypto();
            RSAItem   item = new RSAItem();
            string    privateKey = "", publicKey = "";

            crypto.CreateKeys(out privateKey, out publicKey);
            item.PrivateKey = privateKey;
            item.PublickKey = publicKey;
            item.Guid       = Guid.NewGuid().ToString();
            item.CreateTime = DateTime.Now;
            RedisHelper.Add(item.Guid, item);
            string[] arry = new string[2];
            arry[0] = item.Guid;
            arry[1] = RSAConvert.PemPublicKeyByXml(item.PrivateKey);
            return(arry);
        }
Пример #2
0
        /// <summary>
        /// URL记数统计
        /// </summary>
        /// <param name="url">URL地址</param>
        /// <param name="count">记数统计</param>
        /// <returns></returns>
        public static int GetUrl(string url, int count)
        {
            int res = m_redis.Get <int>(m_cacheHashId, url);

            if (res == 0)
            {
                count = 1;
            }
            else
            {
                count = res + 1;
            }

            m_redis.Add <int>(m_cacheHashId, url, count);

            return(count);
        }
Пример #3
0
        public static void UseDemo()
        {
            var data = new A
            {
                a = "test",
                b = "test for redis",
                c = 1,
                d = 0.2d,
                f = DateTime.Now,
                g = true
            };
            var aKey = "akey";

            redisHelper.Add(aKey, data);           //添加
            var dataB = redisHelper.Get <A>(aKey); //获取

            Console.WriteLine(dataB.a);
            redisHelper.Remove(aKey);                    //删除
            Console.WriteLine(redisHelper.Exists(aKey)); //是否存在
        }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 /// <param name="timeSpan"></param>
 public void Add(string key, object value, TimeSpan timeSpan)
 {
     redisHelper.Add(key, value, (int)timeSpan.TotalSeconds);
 }
Пример #5
0
        public void addData()
        {
            RedisHelper redisHelper = new RedisHelper();

            redisHelper.Add("testC:nothing", "timeYound");
        }