update metodi redis x semplificazione chiamate
This commit is contained in:
@@ -3541,17 +3541,7 @@ namespace MP.IOC.Data
|
||||
|
||||
public bool RedisHashPresent(RedisKey key)
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
result = redisDb.HashExists(key, RedisValue.Empty);
|
||||
}
|
||||
catch (Exception arg)
|
||||
{
|
||||
Log.Error($"Errore in redHashPresent per la currKey {key}{Environment.NewLine}{arg}");
|
||||
}
|
||||
|
||||
return result;
|
||||
return redisDb.KeyExists(key);
|
||||
}
|
||||
|
||||
public bool RedisHashPresentSz(string key)
|
||||
@@ -3574,53 +3564,44 @@ namespace MP.IOC.Data
|
||||
return RedisKeyPresent((RedisKey)key);
|
||||
}
|
||||
|
||||
public bool RedisSetHash(RedisKey redKey, KeyValuePair<string, string>[] valori, double expireSeconds = -1.0)
|
||||
public void RedisSetHash(RedisKey redKey, KeyValuePair<string, string>[] valori, double expireSeconds = -1.0)
|
||||
{
|
||||
bool answ = false;
|
||||
HashEntry[] redHash = valori.Select(x => new HashEntry(x.Key, x.Value)).ToArray();
|
||||
redisDb.HashSet(redKey, redHash);
|
||||
if (expireSeconds > 0.0)
|
||||
{
|
||||
redisDb.KeyExpire(redKey, DateTime.Now.AddSeconds(expireSeconds));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<bool> RedisSetHashAsync(RedisKey redKey, KeyValuePair<string, string>[] valori, double expireSeconds = -1.0)
|
||||
public async Task RedisSetHashAsync(RedisKey redKey, KeyValuePair<string, string>[] valori, double expireSeconds = -1.0)
|
||||
{
|
||||
bool answ = false;
|
||||
HashEntry[] redHash = valori.Select(x => new HashEntry(x.Key, x.Value)).ToArray();
|
||||
await redisDb.HashSetAsync(redKey, redHash);
|
||||
if (expireSeconds > 0.0)
|
||||
{
|
||||
await redisDb.KeyExpireAsync(redKey, DateTime.Now.AddSeconds(expireSeconds));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public bool RedisSetHashDict(RedisKey redKey, Dictionary<string, string> valori, double expireSeconds = -1.0)
|
||||
public void RedisSetHashDict(RedisKey redKey, Dictionary<string, string> valori, double expireSeconds = -1.0)
|
||||
{
|
||||
bool answ = false;
|
||||
HashEntry[] redHash = valori.Select(x => new HashEntry(x.Key, x.Value)).ToArray();
|
||||
redisDb.HashSet(redKey, redHash);
|
||||
if (expireSeconds > 0.0)
|
||||
{
|
||||
redisDb.KeyExpire(redKey, DateTime.Now.AddSeconds(expireSeconds));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<bool> RedisSetHashDictAsync(RedisKey redKey, Dictionary<string, string> valori, double expireSeconds = -1.0)
|
||||
public async Task RedisSetHashDictAsync(RedisKey redKey, Dictionary<string, string> valori, double expireSeconds = -1.0)
|
||||
{
|
||||
bool answ = false;
|
||||
HashEntry[] redHash = valori.Select(x => new HashEntry(x.Key, x.Value)).ToArray();
|
||||
await redisDb.HashSetAsync(redKey, redHash);
|
||||
if (expireSeconds > 0.0)
|
||||
{
|
||||
await redisDb.KeyExpireAsync(redKey, DateTime.Now.AddSeconds(expireSeconds));
|
||||
}
|
||||
answ = true;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4044,7 +4025,8 @@ namespace MP.IOC.Data
|
||||
// se != null --> salvo!
|
||||
if (currDict != null)
|
||||
{
|
||||
fatto = await RedisSetHashDictAsync(currKey, currDict);
|
||||
await RedisSetHashDictAsync(currKey, currDict);
|
||||
fatto = true;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user