mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 11:57:55 +02:00
Use the locking properly, this is not Python...
This commit is contained in:
parent
86940e96d5
commit
d6835f8dd6
1 changed files with 9 additions and 2 deletions
|
@ -90,16 +90,23 @@ namespace MediaBrowser.Providers.TV
|
||||||
{
|
{
|
||||||
return cachedValue;
|
return cachedValue;
|
||||||
}
|
}
|
||||||
using (_cacheWriteLock)
|
|
||||||
|
await _cacheWriteLock.WaitAsync().ConfigureAwait(false);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (_cache.TryGetValue(key, out cachedValue))
|
if (_cache.TryGetValue(key, out cachedValue))
|
||||||
{
|
{
|
||||||
return cachedValue;
|
return cachedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await resultFactory.Invoke();
|
var result = await resultFactory.Invoke();
|
||||||
_cache.Set(key, result, DateTimeOffset.UtcNow.AddHours(1));
|
_cache.Set(key, result, TimeSpan.FromHours(1));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_cacheWriteLock.Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue