Exemple #1
0
    protected void btnReOperate(object sender, EventArgs e)
    {
        RedisNativeClient rclient = new RedisNativeClient("192.168.1.207", 6379);

        try
        {
            string keyval  = key3.Text.Trim();
            int    number  = int.Parse(num.Text.Trim());
            string selflag = Select1.Value;
            long   renum;

            if (selflag.Equals("+"))
            {
                // int.Parse(rclient.Get(key));
                //Int64 re = 0;
                byte[] valueGet = rclient.Get(keyval);
                //if(valueGet == null ||
                //    valueGet.Length <= 0
                //    || valueGet.Length > 8)
                //{
                //    return;
                //}

                //byte[] total = new byte[8];
                //for (int i = 0; i < 8; i++ )
                //{
                //    total[i] = 0;
                //}

                //for (int i = 0; i < valueGet.Length; i++)
                //{
                //    total[i] = valueGet[i];
                //}

                //re = System.BitConverter.ToInt64(total, 0);

                renum = rclient.IncrBy(keyval, number);
                Response.Write("<script>window.alert('" + renum + "');window.location.href='../Mem_RedisTest.aspx'</script>");
            }
            else if (selflag.Equals("-"))
            {
                renum = rclient.DecrBy(keyval, number);
                Response.Write("<script>window.alert('" + renum + "');window.location.href=../Mem_RedisTest.aspx'</script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>window.alert('" + ex.Message + "');window.location.href=../Mem_RedisTest.aspx'</script>");
        }
    }
Exemple #2
0
        public long IncrBy(string key, int count)
        {
            RedisNativeClient client = this.pool.GetRedisClient(key);

            return((client == null) ? 0L : client.IncrBy(key, count));
        }