| | 1 | | using MRA.Infrastructure.Cache; |
| | 2 | | using MRA.Infrastructure.Settings; |
| | 3 | |
|
| | 4 | | namespace MRA.Services.Cache |
| | 5 | | { |
| | 6 | | public class CacheServiceBase |
| | 7 | | { |
| | 8 | | internal readonly ICacheProvider _cache; |
| | 9 | | internal readonly AppSettings _appSettings; |
| | 10 | |
|
| 36 | 11 | | public CacheServiceBase(AppSettings appSettings, ICacheProvider cache) |
| | 12 | | { |
| 36 | 13 | | _cache = cache; |
| 36 | 14 | | _appSettings = appSettings; |
| 36 | 15 | | } |
| | 16 | |
|
| | 17 | | public void CleanCacheItem(string item) |
| | 18 | | { |
| 0 | 19 | | _cache.ClearCacheItem(item); |
| 0 | 20 | | } |
| | 21 | | public void Clear() |
| | 22 | | { |
| 0 | 23 | | _cache.Clear(); |
| 0 | 24 | | } |
| | 25 | |
|
| | 26 | | public T GetOrSetFromCache<T>(string cacheKey, Func<T> getDataFunc) |
| | 27 | | { |
| 0 | 28 | | return _cache.GetOrSetFromCache(cacheKey, getDataFunc); |
| | 29 | | } |
| | 30 | |
|
| | 31 | | public async Task<T> GetOrSetFromCacheAsync<T>(string cacheKey, Func<Task<T>> getDataFunc, bool useCache) |
| | 32 | | { |
| 34 | 33 | | return await _cache.GetOrSetFromCacheAsync(cacheKey, getDataFunc, useCache); |
| 34 | 34 | | } |
| | 35 | | } |
| | 36 | | } |