public void Put <T>(string key, T item) { lock (_padlock) { SqlCache.Put(key, item.ToByteArray()); InMemoryCache.Put(key, item); } }
public WheelEntity Get(WheelFilter filter) { var wheel = _inMemoryCache.Get(filter.ManufacturerName); if (wheel == null) { wheel = _repository.Get(filter); _inMemoryCache.Put(filter.ManufacturerName, wheel); } return(wheel); }
public CarPaintEntity Get(PaintFilter filter) { var paint = _inMemoryCache.Get(filter.Name); if (paint == null) { paint = _repository.Get(filter); _inMemoryCache.Put(filter.Name, paint); } return(paint); }
public TyreEntity Get(TyreFilter filter) { var tyre = _inMemoryCache.Get(filter.WheelManufacturerName); if (tyre == null) { tyre = _repository.Get(filter); _inMemoryCache.Put(filter.WheelManufacturerName, tyre); } return(tyre); }
public CarEngineEntity Get(EngineFilter filter) { var engine = _inMemoryCache.Get(filter.ManufacturerName); if (engine == null) { engine = _repository.Get(filter); _inMemoryCache.Put(filter.ManufacturerName, engine); } return(engine); }
private T TryGetFromMemoryThenFromSource <T>(string key) { T cacheItem; lock (_padlock) { cacheItem = InMemoryCache.Get <T>(key); if (cacheItem == null) { // Key not in cache, so get data. cacheItem = SqlCache.Get <T>(key); if (cacheItem != null) { InMemoryCache.Put(key, cacheItem); } } } return(cacheItem); }