aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaus Vium <clausvium@gmail.com>2019-02-07 21:05:58 +0100
committerClaus Vium <clausvium@gmail.com>2019-02-15 19:33:10 +0100
commitd6835f8dd6eb4ee2d397e682bb300b9f19ce23dc (patch)
tree0f245067ce1442e10ca11a7db30109da194cc674
parent86940e96d51d9259fe6a9795e477f4ef0644a27e (diff)
Use the locking properly, this is not Python...
-rw-r--r--MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs11
1 files changed, 9 insertions, 2 deletions
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs b/MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs
index ca50d4c2b..276622666 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvDbClientManager.cs
@@ -90,16 +90,23 @@ namespace MediaBrowser.Providers.TV
{
return cachedValue;
}
- using (_cacheWriteLock)
+
+ await _cacheWriteLock.WaitAsync().ConfigureAwait(false);
+ try
{
if (_cache.TryGetValue(key, out cachedValue))
{
return cachedValue;
}
+
var result = await resultFactory.Invoke();
- _cache.Set(key, result, DateTimeOffset.UtcNow.AddHours(1));
+ _cache.Set(key, result, TimeSpan.FromHours(1));
return result;
}
+ finally
+ {
+ _cacheWriteLock.Release();
+ }
}
}
}