Skip to content

Commit 6126f20

Browse files
claudiamurialdoclaudiamurialdo
andauthored
Add local memory cache to Redis implementation to reduce roundtrips (#1214)
* Add local memory cache to Redis implementation to reduce roundtrips * It seems better to keep GxRedis.cs unified for both .NET Framework and .NET Core. * Applied Fazzato’s review suggestions * Fix build error. * Read ENABLE_MEMORY_CACHE from provider settings and apply it only in the default constructor used by CacheAPI. * Refactor local cache settings in Redis implementation to support configurable maximum TTL and adjust local cache factor to 20%. --------- Co-authored-by: claudiamurialdo <[email protected]>
1 parent e700afa commit 6126f20

File tree

4 files changed

+235
-20
lines changed

4 files changed

+235
-20
lines changed

dotnet/src/dotnetcore/GxClasses/Services/Session/GXSessionFactory.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ public class GXSessionServiceFactory
1919
private static readonly IGXLogger log = GXLoggerFactory.GetLogger<GXSessionServiceFactory>();
2020

2121
static ISessionService sessionService;
22-
static string REDIS = "REDIS";
23-
static string DATABASE = "DATABASE";
2422
public static ISessionService GetProvider()
2523
{
2624
if (sessionService != null)
@@ -35,9 +33,9 @@ public static ISessionService GetProvider()
3533
//Compatibility
3634
if (string.IsNullOrEmpty(className))
3735
{
38-
if (providerService.Name.Equals(REDIS, StringComparison.OrdinalIgnoreCase))
36+
if (providerService.Name.Equals(GXServices.REDIS_CACHE_SERVICE, StringComparison.OrdinalIgnoreCase))
3937
type = typeof(GxRedisSession);
40-
else if (providerService.Name.Equals(DATABASE, StringComparison.OrdinalIgnoreCase))
38+
else if (providerService.Name.Equals(GXServices.DATABASE_CACHE_SERVICE, StringComparison.OrdinalIgnoreCase))
4139
type = typeof(GxDatabaseSession);
4240
}
4341
else

dotnet/src/dotnetcore/Providers/Cache/GxRedis/GxRedis.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<Compile Include="..\..\..\..\dotnetframework\Providers\Cache\GxRedis\GxRedis.cs" Link="GxRedis.cs" />
19+
<Compile Include="..\..\..\..\dotnetframework\Providers\Cache\GxRedis\GxRedis.cs" Link="GxRedis.cs" />
2020
</ItemGroup>
2121
<ItemGroup>
2222
<PackageReference Include="StackExchange.Redis" Version="2.9.17" />

dotnet/src/dotnetframework/GxClasses/Services/Storage/GXServices.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class GXServices
1515
public static string STORAGE_SERVICE = "Storage";
1616
public static string STORAGE_APISERVICE = "StorageAPI";
1717
public static string CACHE_SERVICE = "Cache";
18+
public static string REDIS_CACHE_SERVICE = "Redis";
19+
public static string DATABASE_CACHE_SERVICE = "DATABASE";
1820
public static string DATA_ACCESS_SERVICE = "DataAccess";
1921
public static string SESSION_SERVICE = "Session";
2022
public static string WEBNOTIFICATIONS_SERVICE = "WebNotifications";
@@ -47,6 +49,7 @@ public static GXServices Instance
4749
}
4850
set { }
4951
}
52+
5053
public void AddService(string name, GXService service)
5154
{
5255
services[name] = service;

0 commit comments

Comments
 (0)