private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
{
return ConnectionMultiplexer.Connect("localhost,abortConnect=false");
});
public static ConnectionMultiplexer Connection
{
get
{
return lazyConnection.Value;
}
}
public static string ListKeyName = "MessageList";
public HomeController()
{
db = Connection.GetDatabase();
if (db.IsConnected(ListKeyName) && (!db.KeyExists(ListKeyName) || !db.KeyType(ListKeyName).Equals(RedisType.List)))
{
//Add sample data.
db.KeyDelete(ListKeyName);
//Push data from the left
db.ListLeftPush(ListKeyName, "TestMsg1");
db.ListLeftPush(ListKeyName, "TestMsg2");
db.ListLeftPush(ListKeyName, "TestMsg3");
db.ListLeftPush(ListKeyName, "TestMsg4");
}
}
<form action="/Home/SendMessage" method="post"> <input type="text" name="message" style="width:250px" /> <input name="btnSend" value="Send" type="submit" style="margin-left:5px" /> </form>
[HttpPost]
public ActionResult SendMessage(string message)
{
if (db.IsConnected(ListKeyName))
{
db.ListLeftPush(ListKeyName, message);
}
return RedirectToAction("Index");
}
@if (@ViewData["Error"] != null)
{
<h2>@ViewData["Error"]</h2>
}
else
{
<div id="MessageList">
<h3>Latest messages</h3>
@foreach (var msg in Model)
{
<div>@Html.DisplayFor(modelItem => msg) </div>
}
</div>
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有