/** * Provides implementation of Insert method of the ICacheStorage interface. Insert/Add the key * value pair to the store. * * * @param key key * @param item object * @return returns the result of operation. */ @Override public StoreInsResult Insert(Object key, Object item, boolean allowExtentedSize) { try { if (ServerMonitor.getMonitorActivity()) { ServerMonitor.LogClientActivity("Store.Insert", ""); } Object oldItem = _itemDict.get(key); StoreStatus status = HasSpace( (ISizable) ((oldItem instanceof ISizable) ? oldItem : null), (ISizable) item, allowExtentedSize); if (_reportCacheNearEviction) { CheckForStoreNearEviction(); } if (status == StoreStatus.HasNotEnoughSpace) { return StoreInsResult.NotEnoughSpace; } _itemDict.put(key, item); super.Inserted( (ISizable) ((oldItem instanceof ISizable) ? oldItem : null), (ISizable) ((item instanceof ISizable) ? item : null)); if (status == StoreStatus.NearEviction) { // the store is almost full, need to evict. return oldItem != null ? StoreInsResult.SuccessOverwriteNearEviction : StoreInsResult.SuccessNearEviction; } return oldItem != null ? StoreInsResult.SuccessOverwrite : StoreInsResult.Success; } catch (OutOfMemoryError e) { return StoreInsResult.NotEnoughSpace; } catch (RuntimeException e) { throw e; } }