STATS:
- Update visualizzazione ODL ed Energy
This commit is contained in:
@@ -91,9 +91,39 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<List<ConfigModel>> ConfigGetAll()
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.ConfigGetAll().ToList());
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -104,6 +134,7 @@ namespace MP.Data.Services
|
||||
redisConn = null;
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis (tutta)
|
||||
/// </summary>
|
||||
@@ -126,6 +157,40 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco link JQM (totale)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LinkMenu>> ListLinkAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<LinkMenu>? result = new List<LinkMenu>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Menu:ALL";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<LinkMenu>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ListLinkAll());
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<LinkMenu>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ListLinkAll | tipoLink: * | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco link JQM dato filtro tipo
|
||||
/// </summary>
|
||||
@@ -161,39 +226,6 @@ namespace MP.Data.Services
|
||||
Log.Debug($"ListLinkFilt | tipoLink: {tipoLink} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Elenco link JQM (totale)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LinkMenu>> ListLinkAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<LinkMenu>? result = new List<LinkMenu>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Menu:ALL";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<LinkMenu>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ListLinkAll());
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<LinkMenu>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ListLinkAll | tipoLink: * | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato operatore secondo gruppi (macchine/operatore)
|
||||
|
||||
@@ -55,13 +55,57 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
// redis dispose
|
||||
redisConn = null;
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL filtrati x articolo e macchina
|
||||
/// </summary>
|
||||
/// <param name="CodArt">Cod articolo</param>
|
||||
/// <param name="IdxMacchina">Macchina selezionata</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ODLExpModel>> ListODLFilt(string CodArt, string IdxMacchina="*")
|
||||
public async Task<List<ODLExpModel>> ListODLFilt(string CodArt, string IdxMacchina = "*")
|
||||
{
|
||||
// setup parametri costanti
|
||||
bool inCorso = false;
|
||||
@@ -84,7 +128,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ListODLFilt(inCorso,CodArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
|
||||
result = await Task.FromResult(dbController.ListODLFilt(inCorso, CodArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -98,23 +142,6 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.ConfigGetAll().ToList());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
// redis dispose
|
||||
redisConn = null;
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.Conf;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -74,9 +75,39 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Task<List<ConfigModel>> ConfigGetAll()
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.ConfigGetAll().ToList());
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -227,6 +258,22 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina info numPezzi x macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public bool MachProdStRem(string idxMacchina)
|
||||
{
|
||||
bool answ = false;
|
||||
if (MachineProdStatus.ContainsKey(idxMacchina))
|
||||
{
|
||||
MachineProdStatus.Remove(idxMacchina);
|
||||
}
|
||||
answ = true;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva numPezzi x macchina
|
||||
/// </summary>
|
||||
@@ -248,22 +295,6 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina info numPezzi x macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public bool MachProdStRem(string idxMacchina)
|
||||
{
|
||||
bool answ = false;
|
||||
if (MachineProdStatus.ContainsKey(idxMacchina))
|
||||
{
|
||||
MachineProdStatus.Remove(idxMacchina);
|
||||
}
|
||||
answ = true;
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<MappaStatoExpl>> MseGetAll(bool forceDb = false)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
@@ -313,17 +344,12 @@ namespace MP.Data.Services
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Cache breve durata
|
||||
/// </summary>
|
||||
private TimeSpan FastCache = TimeSpan.FromSeconds(5);
|
||||
/// <summary>
|
||||
/// Cache brevissima durata
|
||||
/// </summary>
|
||||
private TimeSpan UltraFastCache = TimeSpan.FromMilliseconds(1500);
|
||||
|
||||
/// <summary>
|
||||
/// Cache lunga durata
|
||||
@@ -331,6 +357,12 @@ namespace MP.Data.Services
|
||||
private TimeSpan LongCache = TimeSpan.FromSeconds(60);
|
||||
|
||||
private int maxAge = 2000;
|
||||
private string redisBaseKey = "MP:ALL:Cache";
|
||||
|
||||
/// <summary>
|
||||
/// Cache brevissima durata
|
||||
/// </summary>
|
||||
private TimeSpan UltraFastCache = TimeSpan.FromMilliseconds(1500);
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.Conf;
|
||||
using MP.Data.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe accesso processi traduzione
|
||||
/// </summary>
|
||||
public class TranslateSrv : BaseServ, IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TranslateSrv(IConfiguration configuration)
|
||||
{
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
sw.Start();
|
||||
_configuration = configuration;
|
||||
// setup compoenti REDIS
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("MP.Voc");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
Log.Error("MP.Voc: ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new Controllers.MpVocController(configuration);
|
||||
InitDict();
|
||||
sw.Stop();
|
||||
Log.Info($"TranslateSrv | MpVocController OK | {sw.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static Controllers.MpVocController dbController { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
// redis dispose
|
||||
redisConn = null;
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis (tutta)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache()
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
// rileggo vocabolario!
|
||||
var rawData = await VocabolarioGetAll();
|
||||
DictVocab = rawData.ToDictionary(kvp => $"{kvp.Lingua}_{kvp.Lemma}".ToUpper(), kvp => kvp.Traduzione);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis per chiave specifica (da redisBaseKey...)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache(string KeyReq)
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:{KeyReq}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LingueModel>> LingueGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<LingueModel>? result = new List<LingueModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Lang";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<LingueModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.LingueGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<LingueModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"LingueGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Traduzione termine
|
||||
/// </summary>
|
||||
/// <param name="lemma"></param>
|
||||
/// <param name="lingua"></param>
|
||||
/// <returns></returns>
|
||||
public string Traduci(string lemma, string lingua = "IT")
|
||||
{
|
||||
string answ = $"[{lemma}.{lingua}]";
|
||||
string key = $"{lingua}_{lemma}".ToUpper();
|
||||
if (DictVocab.ContainsKey(key))
|
||||
{
|
||||
answ = DictVocab[key];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<VocabolarioModel>> VocabolarioGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<VocabolarioModel>? result = new List<VocabolarioModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Voc";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<VocabolarioModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.VocabolarioGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<VocabolarioModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"VocabolarioGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Vocabolario x recupero rapido traduzioni
|
||||
/// </summary>
|
||||
protected static Dictionary<string, string> DictVocab = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
protected ConnectionMultiplexer redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
protected IDatabase redisDb = null!;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private string redisBaseKey = "MP:Voc:Cache";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inizializzazione dict vari
|
||||
/// </summary>
|
||||
private static void InitDict()
|
||||
{
|
||||
// inizializzo dizionario vocabolario
|
||||
var rawData = dbController.VocabolarioGetAll();
|
||||
DictVocab = rawData.ToDictionary(kvp => $"{kvp.Lingua}_{kvp.Lemma}".ToUpper(), kvp => kvp.Traduzione);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user