增加RCU上离线功能,能耗双通道
This commit is contained in:
43
BLWLogProduce/Models/MyPublishRedis.cs
Normal file
43
BLWLogProduce/Models/MyPublishRedis.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using CommonEntity;
|
||||
using CSRedis;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BLWLogProduce.Models
|
||||
{
|
||||
public class MyPublishRedis
|
||||
{
|
||||
public static CSRedisClient? redis4;
|
||||
|
||||
private const string ip = "127.0.0.1";
|
||||
private const string port = "6379";
|
||||
static MyPublishRedis()
|
||||
{
|
||||
var redisHostStr = string.Format("{0}:{1}", ip, port);
|
||||
if (!string.IsNullOrEmpty(redisHostStr))
|
||||
{
|
||||
redis4 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=4");
|
||||
string channel = "__keyevent@4__:expired";
|
||||
var QQQ = new ValueTuple<string, Action<CSRedisClient.SubscribeMessageEventArgs>>(channel, (msg) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var o = JsonSerializer.Deserialize<OnOffLineData>(msg.Body);
|
||||
o.CurrentStatus = "off";
|
||||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(o);
|
||||
|
||||
redis4.Publish("redis-on_off_line", str);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
});
|
||||
redis4.Subscribe(QQQ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MyPublishRedis2
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user