public TSlugEntity GetBySlug(string slug) { if (!HasCache) { return(_slugRepository.GetBySlug(slug)); } var itemCacheKey = GetCacheKey(new object[] { slug }); lock (CacheLock) { if (Cache.Exists <TSlugEntity>(itemCacheKey)) { return(Cache.Get <TSlugEntity>(itemCacheKey)); } var slugEntity = _slugRepository.GetBySlug(slug); Cache.AddAbsolute(slugEntity, itemCacheKey, TimeSpan.FromMinutes(10)); return(slugEntity); } }