Im trying to implement the Redis cache, and I’m seeing some odd behaviour using the following code:
n.b. yes I am trying to remove from cache at the beginning for testing purposes.
public object Any(GetConfigurationPlan request)
{
base.Request.RemoveFromCache(base.Cache, @"Cache:ConfigurationPlan:1");
return base.Request.ToOptimizedResultUsingCache<ConfigurationPlan>(base.Cache, @"Cache:ConfigurationPlan:1", () =>
{
ConfigurationPlan response;
using (var db = DbFactory.Open())
{
CheckTableExistsAndInitialize<ConfigurationPlan>(db);
response = db.SingleById<ConfigurationPlan>(request.ID);
}
return response;
});
}
What I am seeing is after the removal there remains a key in redis with the suffix html.deflate.created and when code continutes after the remove from cache, it does not hit the code which retrieves the entity again from the db. It appears to continue to cache.
This is what I see after removal in Redis
If I manually remove this cache key using the desktop manager, the code again hits the db retrieval code.
Is this the correct approach?, and is there a way I can override the different formats (html etc) to just store the json version? Current when I store, I’m getting 4 entries stored each time and I don’t need or want any of the html versions, as this is in backend micro services.
Before Deletion attempt, I have this in the store:
It should be noted that I am testing this call using a direct url in a browser, so I assume this is why its creating the html entries? Still the issue remains, why do all files not get removed upon delete