I have referred the below doc to implement user session based caching, i can see the caching is working fine, but i need clarity on what is the purpose of the file when we dont have any logic to store anything on it. If i want to customize the code by myself what is expected to be saved in the text file?
private static readonly string _cacheBreakerPath = @"C:\Skyline DataMiner\Documents\Ad hoc cache\resultsCacheBreaker.txt";
private void CheckCacheValidation() {
if (!File.Exists(_cacheBreakerPath)) return;
lock (_groupToCache) {
try { _
logger.Information("Going to remove cache.");
if (!File.Exists(_cacheBreakerPath)) return;_groupToCache.Clear();
File.Delete(_cacheBreakerPath);
_logger.Information("Remove cache.");
}
catch (Exception ex) {
_logger.Error(ex, "Could not delete cache."); } } }
Kindly check the below link for full source code example.
Hi Baranisuha,
The purpose of the resultsCacheBreaker.txt file is to provide a way to clear the cache if it becomes out of sync with the system for any reason. It's an additional safety mechanism, but this situation should actually never occur.
Under normal circumstances, the file does not exist. But if for whatever reason the cache needs to be cleared (without restarting the agent), an empty resultsCacheBreaker.txt can be created. When the code detects this file, it will clear the cache and then delete the file automatically again.