public static void AddBundleToCache(Bundle bundle) { Bundle alreadyThere; _bundlesLock.EnterReadLock(); try { alreadyThere = _bundles.SingleOrDefault(x => x.Hash == bundle.Hash); } finally { _bundlesLock.ExitReadLock(); } if (alreadyThere == null) { AddBundleIfNotThere(bundle); } else { bundle = alreadyThere; } lock (bundle) { if (!IsBundleInCache(bundle)) { var result = bundle.Combine(); _cache.Set(bundle.Hash, result, new CacheItemPolicy() { AbsoluteExpiration = bundle.LastCacheInvalidationDate.AddDays(7) }); } } }