Redis API

<h2>Redis存取</h2>
<div>
<input id="Key" type="text" placeholder="请输入要存的键值" /><input id="Value" type="text" placeholder="请输入要存的值" />
<input id="InRedis" type="button" value="存Redis" /><br />
<div id="Qu" hidden="hidden">
<input id="GetKey" type="text" placeholder="请输入要取的键值" />
<label id="GetValue"></label>
<input id="OutRedis" type="button" value="取Redis" /><br />
</div>
</div>

$(function () {
DataBound();
$("#InRedis").click(function () {
var obj = {
Key: $("#Key").val(), Value: $("#Value").val()
}
$.ajax({
url: "http://localhost:60673/api/EM/RedisInsert",
data: obj,
dataType: "json",
type: "get",
success: function (d) {
if (d > 0) {
alert('存值成功');
}
else {
alert('存值失败');
}
$("#Qu").removeAttr("hidden");
}
})
});
$("#OutRedis").click(function () {
$.ajax({
url: "http://localhost:60673/api/EM/RedisGetStr",
data: { Key: $("#GetKey").val()},
dataType: "json",
type: "get",
success: function (d) {
if (d != null) {
$("#GetValue").text(d);
}
else {
$("#GetValue").text("没取到值");
}
}
})
});

})

原文地址:https://www.cnblogs.com/CoreColor/p/13448923.html