jamesmontemagno/monkey-cache

MonkeyCache.FileStore Add with expireIn = TimeSpan.MaxValue is not working

JMan7777 opened this issue · 3 comments

Hello,

If using MonkeyCache.FileStore and if you try to write a "permanent" entry to the cache e.g.

Barrel.Current.Add("MyKey", "MyData", TimeSpan.MaxValue);

an entry is written to the cache but the value is always null.

At the moment I'm using an ugly workaround but this is no real solution:

public void Add<T>(string key, T data, TimeSpan expireIn, string eTag = null, JsonSerializerSettings jsonSerializationSettings = null) { lock (padlock) { if (expireIn != null && expireIn.Equals(TimeSpan.MaxValue)) { expireIn = TimeSpan.FromDays(3650); //10 years should be enough ;) } Barrel.Current.Add(key, data, expireIn, eTag, jsonSerializationSettings); } }

Thx a lot.

Markus

What platform are you seeing an issue on? I have a unit test in place so shouldnt' be an issue.

Hi,

Platform is Xamarin for Android (latest version).
Development IDE is Visual Studio 2019 Version 16.4.4.
App is build for:
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />

Thx for your help.

Will give it a test thanks