Example #1
0
    protected void btnRedisHadd(object sender, EventArgs e)
    {
        RedisNativeClient rclient = new RedisNativeClient("192.168.1.207", 6379);
        string            keyval  = TextBox1.Text.Trim();
        string            field   = TextBox2.Text.Trim();
        string            val     = TextBox3.Text.Trim();

        byte[] key   = System.Text.Encoding.Default.GetBytes(keyval);
        byte[] value = System.Text.Encoding.Default.GetBytes(val);
        try
        {
            rclient.HSet(field, key, value);
            Response.Write("<script>window.alert('添加成功!');window.location.href='../Mem_RedisTest.aspx'</script>");
        }
        catch
        {
            Response.Write("<script>window.alert('添加失败!');window.location.href='../Mem_RedisTest.aspx'</script>");
        }
    }
Example #2
0
        public long HSet(string key, string field, string value)
        {
            RedisNativeClient client = this.pool.GetRedisClient(key);

            return((client == null) ? 0L : client.HSet(key, UTF8String.ToBytes(field), UTF8String.ToBytes(value)));
        }