-
Dear @raman-m , I would appreciate your assistance with an issue regarding the configuration of an external Redis cache across multiple Ocelot instances that utilize the same backend Redis server and identical route configurations in each instance. Below, I have outlined my cache route policy in relation to the external Redis cache. Redis Configuration code in program.csservices.AddOcelot()
.AddCacheManager(x => x.WithDictionaryHandle())
.AddCacheManager(x =>
{
var redisSettings = configuration.GetSection("RedisSettings");
string redisIp = redisSettings["Ip"];
int redisPort = int.Parse(redisSettings["Port"]);
string redisPassword = redisSettings["Password"]; // Retrieve the password
x.WithRedisConfiguration("redis",
config =>
{
config.WithAllowAdmin()
.WithDatabase(0)
.WithEndpoint(redisIp, redisPort)
.WithPassword(redisPassword); // Apply the password
})
.WithJsonSerializer()
.WithRedisCacheHandle("redis");
}) Route configuration in each Ocelot API gateway instances{
"UpstreamPathTemplate": "/api/test/Employee/GetEmployeeDetails/{EmpCode}",
"UpstreamHttpMethod": [ "Get" ],
"DownstreamPathTemplate": "/test/api/Employee/GetEmployeeDetails/{EmpCode}",
"DownstreamScheme": "https",
"DownstreamHttpMethod": "Get",
"DownstreamHostAndPorts": [
{
"Host": "testdomain.com",
"Port": 443
}
],
"FileCacheOptions": {
"TtlSeconds": 180,
"Region": "testregion"
},
"Key": "testkey1"
} The following are the observation points for which I require clarification:
Please could you suggest what do we need to do differently. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
OK, could you please show examples of these keys? And what’s the difference? Also, please add |
Beta Was this translation helpful? Give feedback.
-
Why did you set up twice? You should call the method only once! P.S.I advise against a hybrid setup such as CacheManager + Redis. CacheManager should only be used for memory caching. We have been using the CacheManager.Core package since 2019, but it appears to be deprecated, with the last version being 2.0.0-beta-1629, released on November 15, 2018. Additionally, the most recent repository release is 1.2.0 , dated December 6, 2018, which is quite outdated. P.P.S.@SheruGaur, please implement Your Own Caching. TODOAs a result, our team plans to discontinue support for the Ocelot.Cache.CacheManager package soon and will update the documentation accordingly. |
Beta Was this translation helpful? Give feedback.
Why did you set up twice? You should call the method only once!
P.S.
I advise against a hybrid setup such as CacheManager + Redis. CacheManager should only be used for memory caching. We have been using the CacheManager.Core package since 2019, but it appears to be deprecated, with the last version being 2.0.0-beta-1629, released on November 15, 2018. Additionally, the most recent repository release is 1.2.0 , dated December 6, 2018, which is quite outdated.
P.P.S.
@Sheru…