-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
I'm trying to use FileCache in a net core project to store some intermediate data between several console app launches. Here is a sample.
`
FileCache.DefaultCacheManager = FileCacheManagers.Hashed;
var fc = new FileCache(@"c:\temp\testcache");
string key = "a1:Settings";
var v = fc.Get(key);
if (v != null)
Console.WriteLine($"Cached item: {v}");
else
Console.WriteLine("Cached item not found");
var itemPolicy = new CacheItemPolicy
{
AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(10),
Priority = CacheItemPriority.NotRemovable
};
if (fc.Add(key, "some string value", itemPolicy))
Console.WriteLine("Cached item added");
else
Console.WriteLine("---- Failed to add the item to the cache ----");
var v2 = fc.Get(key);
if (v2 != null)
Console.WriteLine($"Cached item: {v2}");
else
Console.WriteLine("Cached item not found");
`
In a net core console app the first Get return null always. The second Get returns the test value.
It works as expected in a .NET Framework project. The first Get returns the cached value on the second app launch.
AND it works as expected without the first line (FileCache.DefaultCacheManager = FileCacheManagers.Hashed;)
Metadata
Metadata
Assignees
Labels
No labels