/// <summary> /// Unit of work method that tells the repository to persist the new entity /// </summary> /// <param name="entity">The entity to be created</param> public virtual void PersistNewItem(IEntity entity) { try { PersistNewItem((TEntity)entity); _cache.GetCacheItem(GetCacheKey(entity.Key), () => entity); } catch (Exception) { ////if an exception is thrown we need to remove the entry from cache, this is ONLY a work around because of the way //// that we cache entities: http://issues.umbraco.org/issue/U4-4259 _cache.ClearCacheItem(GetCacheKey(entity.Key)); throw; } }
/// <summary> /// Unit of work method that tells the repository to persist the new entity /// </summary> /// <param name="entity">The entity to be created</param> public virtual void PersistNewItem(IEntity entity) { try { PersistNewItem((TEntity)entity); _cache.GetCacheItem(GetCacheKey(entity.Key), () => entity); } catch (Exception ex) { LogHelper.Error(GetType(), "An error occurred trying to add a new entity", ex); ////if an exception is thrown we need to remove the entry from cache, this is ONLY a work around because of the way //// that we cache entities: http://issues.umbraco.org/issue/U4-4259 _cache.ClearCacheItem(GetCacheKey(entity.Key)); throw; } }
internal static void DeleteRow(IGatewayProviderService gatewayProviderService, IRuntimeCacheProvider cache, IShippingFixedRateTable rateTable, IShipRateTier shipRateTier) { //var row = Rows.FirstOrDefault(x => x.Key == shipRateTier.Key); //if (!Rows.Any() || row == null) return; //if (Rows.IndexOf(Rows.Last()) != Rows.IndexOf(row)) //{ // _shipRateTiers[Rows.IndexOf(row) + 1].RangeLow = row.RangeLow; //} //_shipRateTiers.Remove(row); var row = rateTable.Rows.FirstOrDefault(x => x.Key == shipRateTier.Key); if (!rateTable.Rows.Any() || row == null) { return; } if (rateTable.Rows.IndexOf(rateTable.Rows.Last()) != rateTable.Rows.IndexOf(row)) { rateTable.Rows.First(x => x.RangeLow == row.RangeHigh).RangeLow = row.RangeLow; } // clear the current cached item // TODO : This should use the distributed cache referesher cache.ClearCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey)); gatewayProviderService.Save(rateTable.Rows); gatewayProviderService.Delete(shipRateTier); cache.GetCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey), () => rateTable); }
public List <DtgeManifest> GetAllCachedManifests(bool purgeCache = false) { if (purgeCache) { _cache.ClearCacheItem("skttlDtgeTreeManifests"); } return(_cache.GetCacheItem <List <DtgeManifest> >("skttlDtgeTreeManifests", () => GetAllManifests(), new TimeSpan(1, 0, 0))); }
/// <summary> /// The save. /// </summary> /// <param name="gatewayProviderService"> /// The gateway provider service. /// </param> /// <param name="cache"> /// The cache. /// </param> /// <param name="rateTable"> /// The rate table. /// </param> internal static void Save(IGatewayProviderService gatewayProviderService, IRuntimeCacheProvider cache, IShippingFixedRateTable rateTable) { // clear the current cached item // TODO : This should use the distributed cache referesher cache.ClearCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey)); // persist and enter into cache gatewayProviderService.Save(rateTable.Rows); cache.GetCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey), () => rateTable, TimeSpan.FromHours(6)); }
public void ClearCacheItem(string key) { if (_enableCache == false) { _nullHttpCache.ClearCacheItem(key); } else { _httpCache.ClearCacheItem(key); } }
private void Indexer_IndexOperationComplete(object sender, EventArgs e) { var indexer = (LuceneIndex)sender; _logger.Debug <ExamineManagementController>("Logging operation completed for index {IndexName}", indexer.Name); //ensure it's not listening anymore indexer.IndexOperationComplete -= Indexer_IndexOperationComplete; _logger .Info <ExamineManagementController >($"Rebuilding index '{indexer.Name}' done, {indexer.CommitCount} items committed (can differ from the number of items in the index)"); var cacheKey = "temp_indexing_op_" + indexer.Name; _runtimeCacheProvider.ClearCacheItem(cacheKey); }
/// <summary> /// The delete row. /// </summary> /// <param name="gatewayProviderService"> /// The gateway provider service. /// </param> /// <param name="cache"> /// The cache. /// </param> /// <param name="rateTable"> /// The rate table. /// </param> /// <param name="shipRateTier"> /// The ship rate tier. /// </param> internal static void DeleteRow(IGatewayProviderService gatewayProviderService, IRuntimeCacheProvider cache, IShippingFixedRateTable rateTable, IShipRateTier shipRateTier) { var row = rateTable.Rows.FirstOrDefault(x => x.Key == shipRateTier.Key); if (!rateTable.Rows.Any() || row == null) return; if (rateTable.Rows.IndexOf(rateTable.Rows.Last()) != rateTable.Rows.IndexOf(row)) { rateTable.Rows.First(x => x.RangeLow == row.RangeHigh).RangeLow = row.RangeLow; } // clear the current cached item // TODO : This should use the distributed cache referesher cache.ClearCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey)); gatewayProviderService.Save(rateTable.Rows); gatewayProviderService.Delete(shipRateTier); cache.GetCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey), () => rateTable); }
/// <summary> /// The save. /// </summary> /// <param name="gatewayProviderService"> /// The gateway provider service. /// </param> /// <param name="cache"> /// The cache. /// </param> /// <param name="rateTable"> /// The rate table. /// </param> internal static void Save(IGatewayProviderService gatewayProviderService, IRuntimeCacheProvider cache, IShippingFixedRateTable rateTable) { // clear the current cached item // TODO : This should use the distributed cache referesher cache.ClearCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey)); // persist and enter into cache gatewayProviderService.Save(rateTable.Rows); cache.GetCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey), () => rateTable); }
public void Invalidate(string cacheKey) { _runtimeCache.ClearCacheItem($"TeaCommerce_{cacheKey}"); }