Skip to content

Commit

Permalink
Fixed FileCacheTest.CleanCacheTest
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cole-brown committed Aug 24, 2021
1 parent 4ba4a8d commit 5a2e6c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/FileCache.UnitTests/FileCache.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp5.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
Expand Down
4 changes: 3 additions & 1 deletion src/FileCache/FileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -706,6 +707,7 @@ public void Flush(DateTime minDate, string regionName = null)
cLock.Close();
}
}

/// <summary>
/// Returns the policy attached to a given cache item.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions src/FileCache/FileCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,18 @@ public void WriteSysValue(string filename, long data)
}
}

/// <summary>
/// Writes a long to a system file that is not part of the cache itself,
/// but is used to help it function.
/// </summary>
/// <param name="filename">The name of the sysfile (without directory)</param>
/// <param name="data">The DateTime to write to the file</param>
public void WriteSysValue(string filename, DateTime data)
{
// Convert to long and use long's function.
WriteSysValue(filename, data.ToBinary());
}

/// <summary>
/// This function servies to centralize file stream access within this class.
/// </summary>
Expand Down

0 comments on commit 5a2e6c0

Please sign in to comment.