Skip to content

Commit e46abf1

Browse files
author
claudiamurialdo
committed
Applied Fazzato’s review suggestions
1 parent f97a253 commit e46abf1

File tree

1 file changed

+7
-17
lines changed
  • dotnet/src/dotnetframework/Providers/Cache/GxRedis

1 file changed

+7
-17
lines changed

dotnet/src/dotnetframework/Providers/Cache/GxRedis/GxRedis.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Redis()
8686
private void InitLocalCache()
8787
{
8888
#if NETCORE
89-
if (EnvVarReader.GetEnvironmentValue(GXServices.CACHE_SERVICE, GXServices.REDIS_CACHE_SERVICE, "HYBRID", out string envVarValue) && envVarValue.Equals(true.ToString(), StringComparison.OrdinalIgnoreCase))
89+
if (EnvVarReader.GetEnvironmentValue(GXServices.CACHE_SERVICE, GXServices.REDIS_CACHE_SERVICE, "HYBRID", out string envVarValue) && envVarValue.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase))
9090
{
9191
GXLogging.Debug(log, "Using Redis Hybrid mode with local memory cache.");
9292
_localCache = new MemoryCache(new MemoryCacheOptions());
@@ -425,34 +425,26 @@ private TimeSpan LocalCacheTTL(TimeSpan? ttl)
425425
private void ClearKeyLocal(string key)
426426
{
427427
#if NETCORE
428-
if (_localCache == null)
429-
return;
430-
_localCache.Remove(key);
428+
_localCache?.Remove(key);
431429
#endif
432430
}
433431
void ClearAllCachesLocal()
434432
{
435433
#if NETCORE
436-
if (_localCache == null)
437-
return;
438-
_localCache.Compact(1.0);
434+
_localCache?.Compact(1.0);
439435
#endif
440436
}
441437

442438
private void KeyExpireLocal(string fullKey)
443439
{
444440
#if NETCORE
445-
if (_localCache == null)
446-
return;
447-
_localCache.Remove(fullKey);
441+
_localCache?.Remove(fullKey);
448442
#endif
449443
}
450444
private bool KeyExistsLocal(string fullKey)
451445
{
452446
#if NETCORE
453-
if (_localCache == null)
454-
return false;
455-
if (_localCache.TryGetValue(fullKey, out _))
447+
if (_localCache?.TryGetValue(fullKey, out _))
456448
return true;
457449
#endif
458450
return false;
@@ -471,15 +463,13 @@ private void SetLocal<T>(string key, T value)
471463
private void SetPersistentLocal(string cacheid, long? prefix)
472464
{
473465
#if NETCORE
474-
if (_localCache != null)
475-
_localCache.Set(cacheid, prefix, LocalCacheTTL(LOCAL_CACHE_PERSISTENT_KEY_TTL));
466+
_localCache?.Set(cacheid, prefix, LocalCacheTTL(LOCAL_CACHE_PERSISTENT_KEY_TTL));
476467
#endif
477468
}
478469
private void SetLocal<T>(string key, T value, int duration)
479470
{
480471
#if NETCORE
481-
if (_localCache != null)
482-
_localCache.Set(key, value, LocalCacheTTL(duration));
472+
_localCache?.Set(key, value, LocalCacheTTL(duration));
483473
#endif
484474
}
485475
private bool GetLocal<T>(string key, out T value)

0 commit comments

Comments
 (0)