|
@@ -2,6 +2,7 @@
|
|
using FreeRedis;
|
|
using FreeRedis;
|
|
using MessagePack;
|
|
using MessagePack;
|
|
using MessagePack.Resolvers;
|
|
using MessagePack.Resolvers;
|
|
|
|
+using Microsoft.CodeAnalysis.Differencing;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Concurrent;
|
|
@@ -94,7 +95,7 @@ namespace WCS.Service
|
|
//static ConcurrentQueue<PackInfo> Packs = new ConcurrentQueue<PackInfo>();
|
|
//static ConcurrentQueue<PackInfo> Packs = new ConcurrentQueue<PackInfo>();
|
|
private static Dictionary<string, Playerback> Clients = new Dictionary<string, Playerback>();
|
|
private static Dictionary<string, Playerback> Clients = new Dictionary<string, Playerback>();
|
|
|
|
|
|
- private static RedisClient Redis;
|
|
|
|
|
|
+ //private static RedisClient Redis;
|
|
public static RedisClient YG150Redis;
|
|
public static RedisClient YG150Redis;
|
|
public static RedisClient YGWMS150Redis;
|
|
public static RedisClient YGWMS150Redis;
|
|
public static RedisClient YGWCS150Redis;
|
|
public static RedisClient YGWCS150Redis;
|
|
@@ -102,18 +103,18 @@ namespace WCS.Service
|
|
static ProtocolProxy()
|
|
static ProtocolProxy()
|
|
{
|
|
{
|
|
MessagePackSerializer.DefaultOptions = StandardResolver.Options.WithCompression(MessagePackCompression.Lz4Block);
|
|
MessagePackSerializer.DefaultOptions = StandardResolver.Options.WithCompression(MessagePackCompression.Lz4Block);
|
|
- //Redis = new RedisClient("192.168.249.120,password=123456,database=11");
|
|
|
|
- Redis = new RedisClient("212.64.66.35,database=10");
|
|
|
|
- Redis.Serialize = obj =>
|
|
|
|
- {
|
|
|
|
- var bytes = MessagePackSerializer.Serialize(obj);
|
|
|
|
- return bytes;
|
|
|
|
- };
|
|
|
|
- Redis.DeserializeRaw = (bytes, type) =>
|
|
|
|
- {
|
|
|
|
- var obj = MessagePackSerializer.Deserialize(type, bytes);
|
|
|
|
- return obj;
|
|
|
|
- };
|
|
|
|
|
|
+ ////Redis = new RedisClient("192.168.249.120,password=123456,database=11");
|
|
|
|
+ //Redis = new RedisClient("212.64.66.35,database=10");
|
|
|
|
+ //Redis.Serialize = obj =>
|
|
|
|
+ //{
|
|
|
|
+ // var bytes = MessagePackSerializer.Serialize(obj);
|
|
|
|
+ // return bytes;
|
|
|
|
+ //};
|
|
|
|
+ //Redis.DeserializeRaw = (bytes, type) =>
|
|
|
|
+ //{
|
|
|
|
+ // var obj = MessagePackSerializer.Deserialize(type, bytes);
|
|
|
|
+ // return obj;
|
|
|
|
+ //};
|
|
|
|
|
|
YG150Redis = new RedisClient("192.168.249.150,password=123456,database=1");
|
|
YG150Redis = new RedisClient("192.168.249.150,password=123456,database=1");
|
|
YGWMS150Redis = new RedisClient("192.168.249.150,password=123456,database=0");
|
|
YGWMS150Redis = new RedisClient("192.168.249.150,password=123456,database=0");
|
|
@@ -213,21 +214,27 @@ namespace WCS.Service
|
|
|
|
|
|
var sw = new Stopwatch();
|
|
var sw = new Stopwatch();
|
|
sw.Start();
|
|
sw.Start();
|
|
- Redis.Set(nameof(DeviceDataPack), pack);
|
|
|
|
|
|
+ //Redis.Set(nameof(DeviceDataPack), pack);
|
|
YGWCS150Redis.Set(nameof(DeviceDataPack), pack);
|
|
YGWCS150Redis.Set(nameof(DeviceDataPack), pack);
|
|
sw.Stop();
|
|
sw.Stop();
|
|
Console.ForegroundColor = ConsoleColor.Blue;
|
|
Console.ForegroundColor = ConsoleColor.Blue;
|
|
Console.WriteLine($"Redis耗时{sw.ElapsedMilliseconds}");
|
|
Console.WriteLine($"Redis耗时{sw.ElapsedMilliseconds}");
|
|
Console.ResetColor();
|
|
Console.ResetColor();
|
|
|
|
|
|
- Redis.RPush("Packs", pack);
|
|
|
|
|
|
+ //Redis.RPush("Packs", pack);
|
|
YGWCS150Redis.RPush("Packs", pack);
|
|
YGWCS150Redis.RPush("Packs", pack);
|
|
|
|
|
|
- var len = Redis.LLen("Packs");
|
|
|
|
- if (len > 150000)
|
|
|
|
|
|
+ //var len = Redis.LLen("Packs");
|
|
|
|
+ //if (len > 150000)
|
|
|
|
+ //{
|
|
|
|
+ // Redis.LTrim("Packs", 20000, len);
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var len1 = YGWCS150Redis.LLen("Packs");
|
|
|
|
+ if (len1 > 150000)
|
|
{
|
|
{
|
|
- Redis.LTrim("Packs", 20000, len);
|
|
|
|
- YGWCS150Redis.LTrim("Packs", 20000, len);
|
|
|
|
|
|
+ YGWCS150Redis.LTrim("Packs", 20000, len1);
|
|
}
|
|
}
|
|
|
|
|
|
foreach (var data in AllDatas)
|
|
foreach (var data in AllDatas)
|