From 5a2e6c0200102236e5d4dd2a97684f9088f5563b Mon Sep 17 00:00:00 2001 From: Cole Brown Date: Tue, 24 Aug 2021 08:40:53 -0700 Subject: [PATCH] Fixed FileCacheTest.CleanCacheTest All FileCacheTest unit tests now passing. - 4 HashedFileCacheTest unit tests still failing. FileCacheManager was missing the DateTime version of `WriteSysValue()`. Added it to achieve function parity with `ReadSysValue()` functions. --- src/FileCache.UnitTests/FileCache.UnitTests.csproj | 2 +- src/FileCache/FileCache.cs | 4 +++- src/FileCache/FileCacheManager.cs | 12 ++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/FileCache.UnitTests/FileCache.UnitTests.csproj b/src/FileCache.UnitTests/FileCache.UnitTests.csproj index 5ffe0f1..ccc8f85 100644 --- a/src/FileCache.UnitTests/FileCache.UnitTests.csproj +++ b/src/FileCache.UnitTests/FileCache.UnitTests.csproj @@ -1,6 +1,6 @@  - net452;netcoreapp5.0 + netcoreapp5.0 false true true diff --git a/src/FileCache/FileCache.cs b/src/FileCache/FileCache.cs index 34ad22e..1212e09 100644 --- a/src/FileCache/FileCache.cs +++ b/src/FileCache/FileCache.cs @@ -692,8 +692,9 @@ public void Flush(DateTime minDate, string regionName = null) string policyPath = CacheManager.GetPolicyPath(key, region); string cachePath = CacheManager.GetCachePath(key, region); - // Update the Cache size + // Update the Cache size before flushing this item. CurrentCacheSize = GetCacheSize(); + //if either policy or cache are stale, delete both if (File.GetLastAccessTime(policyPath) < minDate || File.GetLastAccessTime(cachePath) < minDate) { @@ -706,6 +707,7 @@ public void Flush(DateTime minDate, string regionName = null) cLock.Close(); } } + /// /// Returns the policy attached to a given cache item. /// diff --git a/src/FileCache/FileCacheManager.cs b/src/FileCache/FileCacheManager.cs index 2d8bc09..3cf6b71 100644 --- a/src/FileCache/FileCacheManager.cs +++ b/src/FileCache/FileCacheManager.cs @@ -488,6 +488,18 @@ public void WriteSysValue(string filename, long data) } } + /// + /// Writes a long to a system file that is not part of the cache itself, + /// but is used to help it function. + /// + /// The name of the sysfile (without directory) + /// The DateTime to write to the file + public void WriteSysValue(string filename, DateTime data) + { + // Convert to long and use long's function. + WriteSysValue(filename, data.ToBinary()); + } + /// /// This function servies to centralize file stream access within this class. ///