/// <summary> /// Adiciona um novo item. /// </summary> /// <param name="key">Chave do item.</param> /// <param name="item">Instancia do item.</param> /// <returns>Resultado da operação.</returns> public override StoreAddResult Add(object key, object item) { try { if (_itemDict.ContainsKey(key)) { return(StoreAddResult.KeyExists); } StorageProviderBase.StoreStatus status = base.HasSpace((ISizable)item); if (status == StorageProviderBase.StoreStatus.HasNotEnoughSpace) { return(StoreAddResult.NotEnoughSpace); } lock (_itemDict.SyncRoot) { _itemDict.Add(key, item); base.Added(item as ISizable); } if (status == StorageProviderBase.StoreStatus.NearEviction) { return(StoreAddResult.SuccessNearEviction); } } catch (OutOfMemoryException) { return(StoreAddResult.NotEnoughSpace); } return(StoreAddResult.Success); }
/// <summary> /// Insere um novo item. /// </summary> /// <param name="key">Chave do item.</param> /// <param name="item">Instancia do item.</param> /// <returns>Resultado da operação.</returns> public override StoreInsResult Insert(object key, object item) { StoreInsResult notEnoughSpace; try { object obj2 = _itemDict[key]; StorageProviderBase.StoreStatus status = base.HasSpace(obj2 as ISizable, (ISizable)item); if (status == StorageProviderBase.StoreStatus.HasNotEnoughSpace) { return(StoreInsResult.NotEnoughSpace); } lock (_itemDict.SyncRoot) { _itemDict[key] = item; base.Inserted(obj2 as ISizable, item as ISizable); } if (status == StorageProviderBase.StoreStatus.NearEviction) { return((obj2 != null) ? StoreInsResult.SuccessOverwriteNearEviction : StoreInsResult.SuccessNearEviction); } notEnoughSpace = (obj2 != null) ? StoreInsResult.SuccessOverwrite : StoreInsResult.Success; } catch (OutOfMemoryException) { notEnoughSpace = StoreInsResult.NotEnoughSpace; } return(notEnoughSpace); }
/// <summary> /// Adiciona um novo item. /// </summary> /// <param name="key">Chave do item.</param> /// <param name="item">Instancia do item.</param> /// <returns>Resultado da operação.</returns> public override StoreAddResult Add(object key, object item) { try { if (_itemDict.ContainsKey(key)) { return(StoreAddResult.KeyExists); } StorageProviderBase.StoreStatus status = base.HasSpace((ISizable)item); if (status == StorageProviderBase.StoreStatus.HasNotEnoughSpace) { return(StoreAddResult.NotEnoughSpace); } byte[] buffer = StoreItem.ToBinary(key, item, base.CacheContext); lock (_itemDict.SyncRoot) { MmfObjectPtr ptr = _internalStore.Add(buffer); if (ptr == null) { return(StoreAddResult.NotEnoughSpace); } ptr.View.ParentStorageProvider = this; _itemDict.Add(key, ptr); base.Added(item as ISizable); } if (status == StorageProviderBase.StoreStatus.NearEviction) { return(StoreAddResult.SuccessNearEviction); } } catch (OutOfMemoryException exception) { Trace.Error("OutofMemoryException::MmfStorageProvider.Add()".GetFormatter(), exception.GetFormatter()); return(StoreAddResult.NotEnoughSpace); } catch (Exception exception2) { Trace.Error("General Exception::MmfStorageProvider.Add()".GetFormatter(), exception2.GetFormatter()); return(StoreAddResult.Failure); } return(StoreAddResult.Success); }
/// <summary> /// Adiciona um novo item. /// </summary> /// <param name="key">Chave do item.</param> /// <param name="item">Instancia do item.</param> /// <returns>Resultado da operação.</returns> public override StoreAddResult Add(object key, object item) { try { if (_itemDict.ContainsKey(key)) { return(StoreAddResult.KeyExists); } StorageProviderBase.StoreStatus status = base.HasSpace((ISizable)item); if (status == StorageProviderBase.StoreStatus.HasNotEnoughSpace) { return(StoreAddResult.NotEnoughSpace); } lock (_itemDict) { object obj2 = _internalStore.Add(key, item, base.CacheContext); if (obj2 != null) { _itemDict.Add(key, obj2); this.SetStateChanged(); base.Added(item as ISizable); } } if (status == StorageProviderBase.StoreStatus.NearEviction) { return(StoreAddResult.SuccessNearEviction); } } catch (OutOfMemoryException exception) { Colosoft.Logging.Trace.Error("FileSystemStorageProvider.Add()".GetFormatter(), exception.GetFormatter()); return(StoreAddResult.NotEnoughSpace); } catch (Exception exception2) { Colosoft.Logging.Trace.Error("FileSystemStorageProvider.Add()".GetFormatter(), exception2.GetFormatter()); return(StoreAddResult.Failure); } return(StoreAddResult.Success); }
/// <summary> /// Insere um novo item. /// </summary> /// <param name="key">Chave do item.</param> /// <param name="item">Instancia do item.</param> /// <returns>Resultado da operação.</returns> public override StoreInsResult Insert(object key, object item) { try { object obj2 = this.Get(key); StorageProviderBase.StoreStatus status = base.HasSpace((ISizable)item); if (status == StorageProviderBase.StoreStatus.HasNotEnoughSpace) { return(StoreInsResult.NotEnoughSpace); } lock (_itemDict) { object obj3 = _internalStore.Insert(_itemDict[key], item, base.CacheContext); if (obj3 == null) { return(StoreInsResult.Failure); } _itemDict[key] = obj3; this.SetStateChanged(); base.Inserted(obj2 as ISizable, item as ISizable); } if (status == StorageProviderBase.StoreStatus.NearEviction) { return((obj2 != null) ? StoreInsResult.SuccessOverwriteNearEviction : StoreInsResult.SuccessNearEviction); } return((obj2 != null) ? StoreInsResult.SuccessOverwrite : StoreInsResult.Success); } catch (OutOfMemoryException exception) { Colosoft.Logging.Trace.Error("FileSystemStorageProvider.Insert()".GetFormatter(), exception.GetFormatter()); return(StoreInsResult.NotEnoughSpace); } catch (Exception exception2) { Colosoft.Logging.Trace.Error("FileSystemStorageProvider.Insert()".GetFormatter(), exception2.GetFormatter()); return(StoreInsResult.Failure); } }
/// <summary> /// Insere um novo item. /// </summary> /// <param name="key">Chave do item.</param> /// <param name="item">Instancia do item.</param> /// <returns>Resultado da operação.</returns> public override StoreInsResult Insert(object key, object item) { StoreInsResult notEnoughSpace; try { MmfObjectPtr info = (MmfObjectPtr)_itemDict[key]; object obj2 = null; if (info == null) { switch (this.Add(key, item)) { case StoreAddResult.NotEnoughSpace: return(StoreInsResult.NotEnoughSpace); case StoreAddResult.Failure: return(StoreInsResult.Failure); } return(StoreInsResult.Success); } obj2 = this.Get(key); StorageProviderBase.StoreStatus status = base.HasSpace(obj2 as ISizable, (ISizable)item); if (status == StorageProviderBase.StoreStatus.HasNotEnoughSpace) { notEnoughSpace = StoreInsResult.NotEnoughSpace; } else { byte[] buffer = StoreItem.ToBinary(key, item, base.CacheContext); lock (_itemDict.SyncRoot) { MmfObjectPtr ptr2 = _internalStore.Insert(info, buffer); if (ptr2 == null) { return(StoreInsResult.NotEnoughSpace); } if (ptr2.Area != info.Area) { _itemDict[key] = ptr2; _internalStore.Remove(info); } base.Inserted(obj2 as ISizable, item as ISizable); if (status == StorageProviderBase.StoreStatus.NearEviction) { return((obj2 != null) ? StoreInsResult.SuccessOverwriteNearEviction : StoreInsResult.SuccessNearEviction); } notEnoughSpace = (ptr2 != null) ? StoreInsResult.SuccessOverwrite : StoreInsResult.Success; } } } catch (OutOfMemoryException exception) { Trace.Error("MmfStorageProvider.Insert()".GetFormatter(), exception.GetFormatter()); notEnoughSpace = StoreInsResult.NotEnoughSpace; } catch (Exception exception2) { Trace.Error("MmfStorageProvider.Insert()".GetFormatter(), exception2.GetFormatter()); notEnoughSpace = StoreInsResult.Failure; } return(notEnoughSpace); }