I started using this in my project, and initial testing went well. Then, I realised that only few values were stored in the cache.
I then created the following test (NUnit) to verify whether the IDistributedFileStoreCacheClass was working fine:
namespaceCaching{publicclassCachingTests{IDistributedFileStoreCacheClassfileCache;[OneTimeSetUp]publicvoidFileCacheSetup(){varservices=new ServiceCollection();//services.AddTransient<IMatchRepository, MatchRepositoryStub>(); // another example of adding service
services.AddDistributedFileStoreCache(options =>{ options.WhichVersion = FileStoreCacheVersions.Class; options.SecondPartOfCacheFileName ="CachingTests"; options.PathToCacheFileDirectory =@"C:\temp";});varserviceProvider= services.BuildServiceProvider();fileCache= serviceProvider.GetService<IDistributedFileStoreCacheClass>();
fileCache.ShouldNotBeNull();}[TestCase(1)][TestCase(5)][TestCase(10)][TestCase(20)][TestCase(50)][TestCase(100)][TestCase(500)][TestCase(1000)][TestCase(10000)]publicvoidFileCacheTest_ManyEntries(intlength){List<string>keys=new();Randomrandom=new Random(0);for(inti=0;i<length;i++){vardata= AutoBogus.AutoFaker.Generate<NominatimData>();stringkey=$"{random.Next()}";
keys.Add(key);
fileCache.SetClass(key, data);}foreach(var key in keys){varfromCache= fileCache.GetClass<NominatimData>(key);
fromCache.ShouldNotBeNull();}}}}
This passes for the first TestCase values (until 10, inclusive) but for higher numbers it fails on fromCache.ShouldNotBeNull(). The values are not written to the file anymore after about 10 values.
Can you please guide me a little that, how to configure it for AWS Load Balancer? Because the JSON file needs to keep a central place so it can be accessed by each instance.
I trying to use this with Kubernetes using a Persistent Volume for storage. The basics are working - the cache file is updated. However updates does not seem to get propagated to the other instances. I'm guessing it is FileSystemWatcher that does work.
Do you have experience using the lib in Kubernetes?