protected void btnRePend(object sender,EventArgs e) { RedisNativeClient rclient = new RedisNativeClient("192.168.1.207", 6379); string pkey = pendkey.Text.Trim(); string select = Sele.Value; byte[] b = { 49, 50, 51 }; if (select.Equals("Prepend")) { Response.Write("<script>window.alert('Redis无法向前追加数据!');window.location.href='../Mem_RedisTest.aspx'</script>"); } else if (select.Equals("Append")) { try { if (rclient.Exists(pkey) == 1) { rclient.Append(pkey, b); Response.Write("<script>window.alert('追加数据成功!');window.location.href='../Mem_RedisTest.aspx'</script>"); } else 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>"); } } }
public long Append(string key, string value) { if (!this.IsValidValue(value)) { return(0L); } // Get the corresponding Redis client. RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? 0L : client.Append(key, UTF8String.ToBytes(value))); }