public void GetEntryClone(CacheEntry cacheEntry, out CacheEntry entry, out Array userPayload, out long payLoadSize) { entry = null; userPayload = null; payLoadSize = 0; try { if (cacheEntry != null) { entry = cacheEntry.CloneWithoutValue() as CacheEntry; if (entry.Value is CallbackEntry) { CallbackEntry cbEntry = ((CallbackEntry)cacheEntry.Value); userPayload = cbEntry.UserData; } else { userPayload = cacheEntry.UserData; } payLoadSize = cacheEntry.DataSize; } } catch (Exception ex) { if (_context.NCacheLog != null) { if (_context.NCacheLog.IsErrorEnabled) { _context.NCacheLog.Error("ObjectDataFormatService.GetCacheData()", ex.Message); } } } }
/// <summary> /// Gets the deflatted value of the of the object in the value. It does not /// deflatten the actual object. /// </summary> internal object DeflattedValue(string cacheContext) { object obj = Value; //There is possibility that two threads simultaneously do deserialization; therefore //we must deserialize the entry in synchronized fashion. lock (this) { if (IsFlattened) { // Setting the Value resets the Flat flag! UserBinaryObject ub = null; CallbackEntry cbEntry = obj as CallbackEntry; if (cbEntry != null) { ub = cbEntry.Value as UserBinaryObject; } else { ub = obj as UserBinaryObject; } byte[] data = ub.GetFullObject(); _size = data.Length; obj = CompactBinaryFormatter.FromByteBuffer(data, cacheContext); if (cbEntry != null) { cbEntry.Value = obj; obj = cbEntry; } } } return(obj); }
internal void AddCallbackInfo(CallbackInfo updateCallback, CallbackInfo removeCallback) { lock (this) { CallbackEntry cbEntry; if (Value is CallbackEntry) { cbEntry = Value as CallbackEntry; } else { cbEntry = new CallbackEntry(); cbEntry.Value = Value; cbEntry.Flag = Flag; Value = cbEntry; } if (updateCallback != null) { cbEntry.AddItemUpdateCallback(updateCallback); } if (removeCallback != null) { cbEntry.AddItemRemoveCallback(removeCallback); } } }
internal void RemoveCallbackInfo(CallbackInfo updateCallback, CallbackInfo removeCallback) { lock (this) { if (updateCallback != null || removeCallback != null) { CallbackEntry cbEntry = null; if (Value is CallbackEntry) { cbEntry = Value as CallbackEntry; if (updateCallback != null && updateCallback.CallbackType == CallbackType.PushBasedNotification) { cbEntry.RemoveItemUpdateCallback(updateCallback); } if (removeCallback != null && removeCallback.CallbackType == CallbackType.PushBasedNotification) { cbEntry.RemoveItemRemoveCallback(removeCallback); } } } //dont use else as currently both pull and push can be confiured simoultaneously //if pullbased notifications { if (updateCallback != null) { RemoveItemUpdateCallback(updateCallback); } if (removeCallback != null) { RemoveItemRemoveCallback(removeCallback); } } } }
public object Clone() { CallbackEntry cloned = new CallbackEntry(); cloned._flag = this._flag; cloned._value = this._value; cloned._itemRemovedListener = this._itemRemovedListener.Clone() as ArrayList; cloned._itemUpdateListener = this._itemUpdateListener.Clone() as ArrayList; return(cloned); }
public object Clone() { CallbackEntry cloned = new CallbackEntry(); cloned._flag = this._flag; cloned._value = this._value; cloned._itemRemovedListener = this._itemRemovedListener.Clone() as ArrayList; cloned._itemUpdateListener = this._itemUpdateListener.Clone() as ArrayList; cloned._onAsyncOperationCompleteCallback = this._onAsyncOperationCompleteCallback; cloned._onWriteBehindOperationCompletedCallback = this._onWriteBehindOperationCompletedCallback; return(cloned); }
/// <summary> /// Creates a new object that is a copy of the current instance. The value is not copied. /// </summary> /// <returns>A new object that is a copy of this instance without value.</returns> public CacheEntry CloneWithoutValue() { CacheEntry e = new CacheEntry(); lock (this) { e._exh = _exh; e._evh = _evh; if (this._grpInfo != null) { e._grpInfo = (GroupInfo)this._grpInfo.Clone(); } e._bitset = (BitSet)_bitset.Clone(); e._syncDependency = _syncDependency; e._queryInfo = _queryInfo; if (_keysDependingOnMe != null) { e._keysDependingOnMe = _keysDependingOnMe.Clone() as HashVector; } if (this.LockMetaInfo != null) { e.LockId = this.LockId; e.LockDate = this.LockDate; e.LockAge = this.LockAge; e.LockExpiration = this.LockExpiration; e.LockMetaInfo.LockManager = this.LockMetaInfo.LockManager; } e._size = _size; e._version = this._version; e._creationTime = this._creationTime; e._lastModifiedTime = this._lastModifiedTime; e._resyncProviderName = this._resyncProviderName; e._providerName = this._providerName; if (this.Value is CallbackEntry) { CallbackEntry cbEntry = (CallbackEntry)this.Value; cbEntry = cbEntry.Clone() as CallbackEntry; cbEntry.Value = null; e.Value = cbEntry; } e._type = _type; e._itemRemovedListener = _itemRemovedListener; e._itemUpdateListener = _itemUpdateListener; } return(e); }
internal void AddCallbackInfo(CallbackInfo updateCallback, CallbackInfo removeCallback) { lock (this) { CallbackEntry cbEntry; bool isPullBasedCallback = false; //pullbasedNotification if (updateCallback != null && updateCallback.CallbackType == CallbackType.PullBasedCallback) { AddItemUpdateCallback(updateCallback); isPullBasedCallback = true; } if (removeCallback != null && removeCallback.CallbackType == CallbackType.PullBasedCallback) { AddItemRemoveCallback(removeCallback); isPullBasedCallback = true; } if (!isPullBasedCallback) { if (Value is CallbackEntry) { cbEntry = Value as CallbackEntry; } else { cbEntry = new CallbackEntry(); cbEntry.Value = Value; cbEntry.Flag = Flag; Value = cbEntry; } if (updateCallback != null) { cbEntry.AddItemUpdateCallback(updateCallback); } if (removeCallback != null) { cbEntry.AddItemRemoveCallback(removeCallback); } } } }
internal void RemoveCallbackInfo(CallbackInfo updateCallback, CallbackInfo removeCallback) { lock (this) { if (updateCallback != null || removeCallback != null) { CallbackEntry cbEntry = null; if (Value is CallbackEntry) { cbEntry = Value as CallbackEntry; if (updateCallback != null) { cbEntry.RemoveItemUpdateCallback(updateCallback); } if (removeCallback != null) { cbEntry.RemoveItemRemoveCallback(removeCallback); } } } } }
/// <summary> /// Creates a new object that is a copy of the current instance. The value is not copied. /// </summary> /// <returns>A new object that is a copy of this instance without value.</returns> public CacheEntry CloneWithoutValue() { CacheEntry e = new CacheEntry(); lock (this) { e._exh = _exh; e._evh = _evh; e._bitset = (BitSet)_bitset.Clone(); e._queryInfo = _queryInfo; if (this.LockMetaInfo != null) { e.LockId = this.LockId; e.LockDate = this.LockDate; e.LockAge = this.LockAge; e.LockExpiration = this.LockExpiration; e.LockMetaInfo.LockManager = this.LockMetaInfo.LockManager; } e._size = _size; e._creationTime = this._creationTime; e._lastModifiedTime = this._lastModifiedTime; if (this.Value is CallbackEntry) { CallbackEntry cbEntry = (CallbackEntry)this.Value; cbEntry = cbEntry.Clone() as CallbackEntry; cbEntry.Value = null; e.Value = cbEntry; } e._type = _type; } return(e); }
/// <summary> /// Insert array of CompactCacheEntry to cache, these may be serialized /// </summary> /// <param name="entries"></param> public IDictionary InsertEntries(object[] entries, OperationContext operationContext) { // check if cache is running. if (!IsRunning) return null; string[] keys = new string[entries.Length]; object[] values = new object[entries.Length]; CallbackEntry[] callbackEnteries = new CallbackEntry[entries.Length]; ExpirationHint[] exp = new ExpirationHint[entries.Length]; EvictionHint[] evc = new EvictionHint[entries.Length]; BitSet[] flags = new BitSet[entries.Length]; Hashtable[] queryInfo = new Hashtable[entries.Length]; CallbackEntry cbEntry = null; for (int i = 0; i < entries.Length; i++) { CompactCacheEntry cce = (CompactCacheEntry)SerializationUtil.CompactDeserialize(entries[i], _context.SerializationContext); keys[i] = cce.Key as string; CacheEntry ce = MakeCacheEntry(cce); if (ce != null) { if (ce.Value is CallbackEntry) cbEntry = ce.Value as CallbackEntry; else cbEntry = null; callbackEnteries[i] = cbEntry; object value = ce.Value as CallbackEntry; values[i] = value == null ? ce.Value : ((CallbackEntry)ce.Value).Value; exp[i] = ce.ExpirationHint; evc[i] = ce.EvictionHint; queryInfo[i] = ce.QueryInfo; flags[i] = ce.Flag; } } IDictionary items= Insert(keys, values, callbackEnteries, exp, evc, queryInfo, flags, operationContext); return items; }
public void Delete(string key, BitSet flag, CallbackEntry cbEntry, object lockId, LockAccessType accessType, OperationContext operationContext) { if (key == null) throw new ArgumentNullException("key"); if (!key.GetType().IsSerializable) throw new ArgumentException("key is not serializable"); // Cache has possibly expired so do default. if (!IsRunning) return; try { HPTimeStats removeTime = new HPTimeStats(); removeTime.BeginSample(); _context.PerfStatsColl.MsecPerDelBeginSample(); object packedKey = key; CacheEntry e = CascadedRemove(key, packedKey, ItemRemoveReason.Removed, true, lockId,accessType, operationContext); _context.PerfStatsColl.MsecPerDelEndSample(); _context.PerfStatsColl.IncrementDelPerSecStats(); removeTime.EndSample(); } catch (OperationFailedException ex) { if (ex.IsTracable) _context.NCacheLog.Error("Cache.Delete()", ex.ToString()); throw ex; } catch (Exception inner) { _context.NCacheLog.Error("Cache.Delete()", inner.ToString()); throw new OperationFailedException("Delete operation failed. Error : " + inner.Message, inner); } }
/// <summary> /// Overload of Insert operation for bulk inserts. Uses EvictionHint and ExpirationHint arrays. /// </summary> public IDictionary Insert(object[] keys, object[] values, CallbackEntry[] callbackEnteries, ExpirationHint[] expirations, EvictionHint[] evictions, Hashtable[] queryInfos, BitSet[] flags,OperationContext operationContext) { if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("Cache.InsertBlk", ""); if (keys == null) throw new ArgumentNullException("keys"); if (values == null) throw new ArgumentNullException("items"); if (keys.Length != values.Length) throw new ArgumentException("keys count is not equals to values count"); CacheEntry[] ce = new CacheEntry[values.Length]; long[] sizes = null; object dataSize = operationContext.GetValueByField(OperationContextFieldName.ValueDataSize); if (dataSize != null) { sizes = (long[])dataSize; } for (int i = 0; i < values.Length; i++) { if (keys[i] == null) throw new ArgumentNullException("key"); if (values[i] == null) throw new ArgumentNullException("value"); if (!keys[i].GetType().IsSerializable) throw new ArgumentException("key is not serializable"); if (!values[i].GetType().IsSerializable) throw new ArgumentException("value is not serializable"); if ((expirations[i] != null) && !expirations[i].GetType().IsSerializable) throw new ArgumentException("expiryHint is not not serializable"); if ((evictions[i] != null) && !evictions[i].GetType().IsSerializable) throw new ArgumentException("evictionHint is not serializable"); // Cache has possibly expired so do default. if (!IsRunning) return null; ce[i] = new CacheEntry(values[i], expirations[i], evictions[i]); ce[i].QueryInfo = queryInfos[i]; ce[i].Flag.Data |= flags[i].Data; if(sizes != null) ce[i].DataSize = sizes[i]; if (callbackEnteries[i] != null) { CallbackEntry cloned = callbackEnteries[i].Clone() as CallbackEntry; cloned.Value = values[i]; cloned.Flag = ce[i].Flag; ce[i].Value = cloned; } } /// update the counters for various statistics try { HPTimeStats insertTime = new HPTimeStats(); insertTime.BeginSample(); IDictionary result = Insert(keys, ce, operationContext); insertTime.EndSample(); return result; } catch (Exception inner) { throw; } }
//PROTOBUF protected CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager, string cacheId) { CommandInfo cmdInfo = new CommandInfo(); int packageSize = 0; int index = 0; string version = string.Empty; switch (command.type) { case Alachisoft.NCache.Common.Protobuf.Command.Type.ADD_BULK: Alachisoft.NCache.Common.Protobuf.BulkAddCommand bulkAddCommand = command.bulkAddCommand; packageSize = bulkAddCommand.addCommand.Count; cmdInfo.Keys = new string[packageSize]; cmdInfo.UpdateCallbackId = new short[packageSize]; cmdInfo.UpdateDataFilter = new int[packageSize]; cmdInfo.RemoveCallbackId = new short[packageSize]; cmdInfo.RemoveDataFilter = new int[packageSize]; cmdInfo.CallbackEnteries = new CallbackEntry[packageSize]; cmdInfo.EvictionHint = new PriorityEvictionHint[packageSize]; cmdInfo.ExpirationHint = new ExpirationHint[packageSize]; cmdInfo.Flags = new BitSet[packageSize]; cmdInfo.Values = new object[packageSize]; cmdInfo.QueryInfo = new Hashtable[packageSize]; cmdInfo.RequestId = bulkAddCommand.requestId.ToString(); cmdInfo.ClientLastViewId = command.clientLastViewId; cmdInfo.IntendedRecipient = command.intendedRecipient; foreach (Alachisoft.NCache.Common.Protobuf.AddCommand addCommand in bulkAddCommand.addCommand) { cmdInfo.Keys[index] = addCommand.key; cmdInfo.UpdateCallbackId[index] = (short)addCommand.updateCallbackId; if (addCommand.updateDataFilter != -1) cmdInfo.UpdateDataFilter[index] = addCommand.updateDataFilter; else cmdInfo.UpdateDataFilter[index] = (int) EventDataFilter.None; cmdInfo.RemoveCallbackId[index] = (short)addCommand.removeCallbackId; if (addCommand.removeDataFilter != -1) cmdInfo.RemoveDataFilter[index] = addCommand.removeDataFilter; else cmdInfo.RemoveDataFilter[index] = (int)EventDataFilter.DataWithMetadata; cmdInfo.EvictionHint[index] = new PriorityEvictionHint((CacheItemPriority)addCommand.priority); cmdInfo.ExpirationHint[index] = Alachisoft.NCache.Caching.Util.ProtobufHelper.GetExpirationHintObj(addCommand.absExpiration, addCommand.sldExpiration, serailizationContext); cmdInfo.Flags[index] = new BitSet((byte)addCommand.flag); CallbackEntry cbEntry = null; if (cmdInfo.UpdateCallbackId[index] != -1 || cmdInfo.RemoveCallbackId[index] != -1) { cbEntry = new CallbackEntry(ClientId, Convert.ToInt32(cmdInfo.RequestId), cmdInfo.Values[index], cmdInfo.RemoveCallbackId[index], cmdInfo.UpdateCallbackId[index], cmdInfo.Flags[index], (EventDataFilter)cmdInfo.UpdateDataFilter[index], (EventDataFilter)cmdInfo.RemoveDataFilter[index] ); } cmdInfo.CallbackEnteries[index] = cbEntry; Hashtable queryInfo = new Hashtable(); version = command.version; if (string.IsNullOrEmpty(version)) { queryInfo["query-info"] = Alachisoft.NCache.Caching.Util.ProtobufHelper.GetHashtableFromQueryInfoObj(addCommand.queryInfo); } else { ObjectQueryInfo objectQueryInfo; objectQueryInfo = addCommand.objectQueryInfo; queryInfo["query-info"] = Alachisoft.NCache.Caching.Util.ProtobufHelper.GetHashtableFromQueryInfoObj(objectQueryInfo.queryInfo); } cmdInfo.QueryInfo[index] = queryInfo; cmdInfo.Values[index] = UserBinaryObject.CreateUserBinaryObject(addCommand.data.ToArray()); index++; } break; case Alachisoft.NCache.Common.Protobuf.Command.Type.INSERT_BULK: Alachisoft.NCache.Common.Protobuf.BulkInsertCommand bulkInsertCommand = command.bulkInsertCommand; packageSize = bulkInsertCommand.insertCommand.Count; cmdInfo.Keys = new string[packageSize]; cmdInfo.UpdateCallbackId = new short[packageSize]; cmdInfo.UpdateDataFilter = new int[packageSize]; cmdInfo.RemoveCallbackId = new short[packageSize]; cmdInfo.RemoveDataFilter = new int[packageSize]; cmdInfo.CallbackEnteries = new CallbackEntry[packageSize]; cmdInfo.EvictionHint = new PriorityEvictionHint[packageSize]; cmdInfo.ExpirationHint = new ExpirationHint[packageSize]; cmdInfo.Flags = new BitSet[packageSize]; cmdInfo.Values = new object[packageSize]; cmdInfo.QueryInfo = new Hashtable[packageSize]; cmdInfo.RequestId = bulkInsertCommand.requestId.ToString(); cmdInfo.ClientLastViewId = command.clientLastViewId; cmdInfo.IntendedRecipient = command.intendedRecipient; foreach (Alachisoft.NCache.Common.Protobuf.InsertCommand insertCommand in bulkInsertCommand.insertCommand) { cmdInfo.Keys[index] = insertCommand.key; cmdInfo.UpdateCallbackId[index] = (short)insertCommand.updateCallbackId; cmdInfo.RemoveCallbackId[index] = (short)insertCommand.removeCallbackId; if (insertCommand.updateDataFilter != -1) cmdInfo.UpdateDataFilter[index] = insertCommand.updateDataFilter; else cmdInfo.UpdateDataFilter[index] = (int)EventDataFilter.None; //for old clients eventdata filter will be missing if (insertCommand.removeDataFilter != -1) cmdInfo.RemoveDataFilter[index] = insertCommand.removeDataFilter; else cmdInfo.RemoveDataFilter[index] = (int) EventDataFilter.DataWithMetadata; cmdInfo.EvictionHint[index] = new PriorityEvictionHint((CacheItemPriority)insertCommand.priority); cmdInfo.ExpirationHint[index] = Alachisoft.NCache.Caching.Util.ProtobufHelper.GetExpirationHintObj(insertCommand.absExpiration, insertCommand.sldExpiration, serailizationContext); cmdInfo.Flags[index] = new BitSet((byte)insertCommand.flag); CallbackEntry cbEntry = null; if (cmdInfo.UpdateCallbackId[index] != -1 || cmdInfo.RemoveCallbackId[index] != -1) { cbEntry = new CallbackEntry(ClientId, Convert.ToInt32(cmdInfo.RequestId), cmdInfo.Values[index], cmdInfo.RemoveCallbackId[index], cmdInfo.UpdateCallbackId[index], cmdInfo.Flags[index], (EventDataFilter)cmdInfo.UpdateDataFilter[index], (EventDataFilter)cmdInfo.RemoveDataFilter[index] ); } cmdInfo.CallbackEnteries[index] = cbEntry; Hashtable queryInfo = new Hashtable(); version = command.version; if (string.IsNullOrEmpty(version)) { queryInfo["query-info"] = Alachisoft.NCache.Caching.Util.ProtobufHelper.GetHashtableFromQueryInfoObj(insertCommand.queryInfo); } else { ObjectQueryInfo objectQueryInfo; objectQueryInfo = insertCommand.objectQueryInfo; queryInfo["query-info"] = Alachisoft.NCache.Caching.Util.ProtobufHelper.GetHashtableFromQueryInfoObj(objectQueryInfo.queryInfo); } cmdInfo.QueryInfo[index] = queryInfo; cmdInfo.Values[index] = UserBinaryObject.CreateUserBinaryObject(insertCommand.data.ToArray()); index++; } break; } return cmdInfo; }
public object Clone() { CallbackEntry cloned = new CallbackEntry(); cloned._flag = this._flag; cloned._value = this._value; cloned._itemRemovedListener = this._itemRemovedListener.Clone() as ArrayList; cloned._itemUpdateListener = this._itemUpdateListener.Clone() as ArrayList; return cloned; }
/// <summary> /// Create a CompactEntry object /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <param name="absoluteExpiration"></param> /// <param name="slidingExpiration"></param> /// <param name="priority"></param> /// <param name="onRemoveCallback"></param> /// <returns></returns> private object MakeCompactEntry(string key, object value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short onRemoveCallback, short onUpdateCallback, Hashtable queryInfo, BitSet Flag, object lockId, LockAccessType accessType, EventDataFilter updateCallbackFilter, EventDataFilter removeCallabackFilter) { //we create a user binary object. if (this.SerializationEnabled) { value = UserBinaryObject.CreateUserBinaryObject((byte[])value); } if ((short)onRemoveCallback != -1 || (short)onUpdateCallback != -1 ) value = new CallbackEntry(ClientID, -1, value, onRemoveCallback, onUpdateCallback, Flag, updateCallbackFilter, removeCallabackFilter); ////muds: ////we can not specify both tags and groups for the same cache item. //WebCacheHelper.EvaluateTagsParameters(queryInfo, group); byte expType = WebCacheHelper.EvaluateExpirationParameters(absoluteExpiration, slidingExpiration); int options = 0; if (expType < 2) { options = expType; } int prio = Convert.ToInt32(priority); prio += 2; prio = (prio << 2); options = options | prio; long expiration = expType == 1 ? absoluteExpiration.Ticks : slidingExpiration.Ticks; ExpirationHint hint = null; object entry = new CompactCacheEntry(key, value, hint, expiration, (byte)options, null, queryInfo, Flag, lockId, accessType); return entry; }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; NCache nCache = clientManager.CmdExecuter as NCache; try { serializationContext = nCache.CacheId; cmdInfo = base.ParseCommand(command, clientManager, serializationContext); if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("AddCmd.Exec", "cmd parsed"); } catch (Exception exc) { _addResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); return; } CallbackEntry callbackEntry = null; if (cmdInfo.UpdateCallbackId != -1 || cmdInfo.RemoveCallbackId != -1 || !cmdInfo.RequestId.Equals("-1") ) { callbackEntry = new CallbackEntry(clientManager.ClientID, Convert.ToInt32(cmdInfo.RequestId), cmdInfo.value, cmdInfo.RemoveCallbackId, cmdInfo.UpdateCallbackId, cmdInfo.Flag, (EventDataFilter) cmdInfo.UpdateDataFilter, (EventDataFilter) cmdInfo.RemoveDataFilter); } try { OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); nCache.Cache.Add(cmdInfo.Key, callbackEntry == null ? cmdInfo.value : (object)callbackEntry, cmdInfo.ExpirationHint, cmdInfo.EvictionHint, cmdInfo.queryInfo, cmdInfo.Flag, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.AddResponse addResponse = new Alachisoft.NCache.Common.Protobuf.AddResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.ADD; response.addResponse = addResponse; //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _addResult = OperationResult.Failure; _serializedResponsePackets.Add( Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("AddCmd.Exec", "cmd executed on cache"); }
/// <summary> /// Clear all the contents of cache /// </summary> /// <returns></returns> public void Clear(BitSet flag, CallbackEntry cbEntry, OperationContext operationContext) { // Cache has possibly expired so do default. if (!IsRunning) return; try { _context.CacheImpl.Clear(null, operationContext); } catch (Exception inner) { _context.NCacheLog.Error("Cache.Clear()", inner.ToString()); throw new OperationFailedException("Clear operation failed. Error: " + inner.Message, inner); } }
/// <summary> /// Removes the objects for the given keys from the cache. /// The keys are specified as parameter. /// </summary> /// <param name="keys">array of keys to be removed</param> /// <param name="flagMap"></param> /// <param name="cbEntry"></param> /// <param name="operationContext"></param> /// <returns>keys that failed to be removed</returns> public IDictionary Remove(object[] keys, BitSet flagMap, CallbackEntry cbEntry, OperationContext operationContext) { if (keys == null) throw new ArgumentNullException("keys"); // Cache has possibly expired so do default. if (!IsRunning) return null; try { HPTimeStats removeTime = new HPTimeStats(); removeTime.BeginSample(); IDictionary removed = CascadedRemove(keys, ItemRemoveReason.Removed, true, operationContext); removeTime.EndSample(); CompressedValueEntry val = null; if (removed != null) { object[] keysCollection = new object[removed.Count]; removed.Keys.CopyTo(keysCollection, 0); IEnumerator ie = keysCollection.GetEnumerator(); while (ie.MoveNext()) { CacheEntry entry = removed[ie.Current] as CacheEntry; if (entry != null) { val = new CompressedValueEntry(); val.Value = entry.Value; if (val.Value is CallbackEntry) val.Value = ((CallbackEntry)val.Value).Value; val.Flag = entry.Flag; removed[ie.Current] = val; } } } return removed; } catch (Exception inner) { _context.NCacheLog.Error("Cache.Remove()", inner.ToString()); throw new OperationFailedException("Remove operation failed. Error : " + inner.Message, inner); } return null; }
/// <summary> /// Removes the objects for the given keys from the cache. /// The keys are specified as parameter. /// </summary> /// <param name="keys">array of keys to be removed</param> public void Delete(object[] keys, BitSet flagMap, CallbackEntry cbEntry, OperationContext operationContext) { if (keys == null) throw new ArgumentNullException("keys"); // Cache has possibly expired so do default. if (!IsRunning) return; try { HPTimeStats removeTime = new HPTimeStats(); removeTime.BeginSample(); IDictionary removed = CascadedRemove(keys, ItemRemoveReason.Removed, true, operationContext); removeTime.EndSample(); } catch (Exception inner) { _context.NCacheLog.Error("Cache.Delete()", inner.ToString()); throw new OperationFailedException("Delete operation failed. Error : " + inner.Message, inner); } }
internal void AddCallbackInfo(CallbackInfo updateCallback, CallbackInfo removeCallback) { lock (this) { CallbackEntry cbEntry; if (Value is CallbackEntry) { cbEntry = Value as CallbackEntry; } else { cbEntry = new CallbackEntry(); cbEntry.Value = Value; cbEntry.Flag = Flag; Value = cbEntry; } if (updateCallback != null) cbEntry.AddItemUpdateCallback(updateCallback); if (removeCallback != null) cbEntry.AddItemRemoveCallback(removeCallback); } }
/// Removes all entries from the store. /// </summary> public override void Clear(CallbackEntry cbEntry, OperationContext operationContext) { Internal.Clear(cbEntry, operationContext); }