| | | 1 | | using Services.CacheServices; |
| | | 2 | | using Services.CacheServices.Cache; |
| | | 3 | | using Services.CacheServices.Cache.OzonOrdersCache; |
| | | 4 | | |
| | | 5 | | namespace Services.CacheServices.Cache |
| | | 6 | | { |
| | | 7 | | public class CacheUpdater<T> : ICacheUpdater<T> |
| | | 8 | | { |
| | | 9 | | private readonly OrderCache _orderCache; |
| | | 10 | | private readonly TransactionCache _transactionCache; |
| | | 11 | | |
| | | 12 | | |
| | 0 | 13 | | public CacheUpdater(OrderCache orderCache, |
| | 0 | 14 | | TransactionCache transactionCache) |
| | | 15 | | { |
| | 0 | 16 | | _orderCache = orderCache; |
| | 0 | 17 | | _transactionCache = transactionCache; |
| | 0 | 18 | | } |
| | | 19 | | |
| | | 20 | | public async Task Update(IAppCache<T> cacheEntity) |
| | | 21 | | { |
| | 0 | 22 | | await cacheEntity.Update(); |
| | | 23 | | |
| | 0 | 24 | | if (typeof(OrderCache).IsAssignableFrom(cacheEntity.GetType())) |
| | | 25 | | { |
| | 0 | 26 | | await _transactionCache.Update(); |
| | | 27 | | } |
| | 0 | 28 | | if (typeof(ProductCache).IsAssignableFrom(cacheEntity.GetType())) |
| | | 29 | | { |
| | 0 | 30 | | await _orderCache.Update(); |
| | | 31 | | } |
| | | 32 | | |
| | 0 | 33 | | } |
| | | 34 | | |
| | | 35 | | public async Task Update(IRedisAppCache<T> cacheEntity) |
| | | 36 | | { |
| | 0 | 37 | | await cacheEntity.Update(); |
| | | 38 | | |
| | 0 | 39 | | if (typeof(OrderCache).IsAssignableFrom(cacheEntity.GetType())) |
| | | 40 | | { |
| | 0 | 41 | | await _transactionCache.Update(); |
| | | 42 | | } |
| | 0 | 43 | | if (typeof(ProductCache).IsAssignableFrom(cacheEntity.GetType())) |
| | | 44 | | { |
| | 0 | 45 | | await _orderCache.Update(); |
| | | 46 | | } |
| | | 47 | | |
| | 0 | 48 | | } |
| | | 49 | | } |
| | | 50 | | } |