Skip to content

Commit

Permalink
chore: remove invalidation function, offload to consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Jul 31, 2023
1 parent 3fee183 commit fcf95f0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
16 changes: 0 additions & 16 deletions src/CommonLib/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,6 @@ public static void SetCacheInstance(Cache cache)
CreateMissingDictionaries();
}

public static bool CacheNeedsInvalidation(Cache cache, Version version)
{
var threshold = DateTime.Now.Subtract(TimeSpan.FromDays(30));
if (cache.CacheCreationDate < threshold)
{
return true;
}

if (cache.CacheCreationVersion == null || version > cache.CacheCreationVersion)
{
return true;
}

return false;
}

/// <summary>
/// Gets stats from the currently loaded cache
/// </summary>
Expand Down
26 changes: 0 additions & 26 deletions test/unit/CacheTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ public CacheTest(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}

[Fact]
public void Cache_TestCacheInvalidation()
{
var cache = Cache.CreateNewCache();
var version = new Version(1, 0, 0);
cache.CacheCreationVersion = version;

Assert.True(Cache.CacheNeedsInvalidation(cache, new Version(1,0,1)));
Assert.False(Cache.CacheNeedsInvalidation(cache, new Version(1,0,0)));

var time = DateTime.Now.Subtract(TimeSpan.FromDays(29));
cache.CacheCreationDate = time;
Assert.False(Cache.CacheNeedsInvalidation(cache, version));
cache.CacheCreationDate = DateTime.Now.Subtract(TimeSpan.FromDays(31));
Assert.True(Cache.CacheNeedsInvalidation(cache, version));
}

[Fact]
public void Cache_TestNewCache()
Expand All @@ -42,14 +25,5 @@ public void Cache_TestNewCache()
Assert.Equal(cache.CacheCreationVersion, version);
Assert.Equal(cache.CacheCreationDate, time);
}

[Fact]
public void Cache_OldCacheWillInvalidate()
{
const string json = "{\"GlobalCatalogCache\": {}, \"IdToTypeCache\": {}, \"MachineSidCache\": {}, \"SIDToDomainCache\": {}, \"ValueToIdCache\": {}}";
var cache = JsonConvert.DeserializeObject<Cache>(json);
Assert.Null(cache.CacheCreationVersion);
Assert.True(Cache.CacheNeedsInvalidation(cache, new Version(1,0,0)));
}
}
}

0 comments on commit fcf95f0

Please sign in to comment.