/// <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); }
/// <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); }
//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.Entries = new CacheEntry[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.Entries[index] = new CacheEntry(UserBinaryObject.CreateUserBinaryObject(addCommand.data.ToArray()), Alachisoft.NCache.Caching.Util.ProtobufHelper.GetExpirationHintObj(addCommand.absExpiration, addCommand.sldExpiration, serailizationContext), new PriorityEvictionHint((CacheItemPriority)addCommand.priority)); if (index == 0) cmdInfo.Flag = new BitSet((byte)addCommand.flag); CallbackEntry cbEntry = null; if ((short)addCommand.updateCallbackId != -1 || (short)addCommand.removeCallbackId != -1) { cbEntry = new CallbackEntry(ClientId, Convert.ToInt32(cmdInfo.RequestId), UserBinaryObject.CreateUserBinaryObject(addCommand.data.ToArray()), (short)addCommand.removeCallbackId, (short)addCommand.updateCallbackId, new BitSet((byte)addCommand.flag), (EventDataFilter)(addCommand.updateDataFilter != -1 ? (int)addCommand.updateDataFilter : (int)EventDataFilter.None), (EventDataFilter)(addCommand.removeDataFilter != -1 ? (int)addCommand.removeDataFilter : (int)EventDataFilter.DataWithMetadata) ); cmdInfo.Entries[index].Value = cbEntry.Clone(); } 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.Entries[index].QueryInfo = queryInfo; 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.Entries = new CacheEntry[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.Entries[index] = new CacheEntry(UserBinaryObject.CreateUserBinaryObject(insertCommand.data.ToArray()), Alachisoft.NCache.Caching.Util.ProtobufHelper.GetExpirationHintObj(insertCommand.absExpiration, insertCommand.sldExpiration, serailizationContext), new PriorityEvictionHint((CacheItemPriority)insertCommand.priority)); if (index == 0) cmdInfo.Flag = new BitSet((byte)insertCommand.flag); CallbackEntry cbEntry = null; if (insertCommand.updateCallbackId != -1 || insertCommand.removeCallbackId != -1) { cbEntry = new CallbackEntry(ClientId, Convert.ToInt32(cmdInfo.RequestId), UserBinaryObject.CreateUserBinaryObject(insertCommand.data.ToArray()), (short)insertCommand.removeCallbackId, (short)insertCommand.updateCallbackId, new BitSet((byte)insertCommand.flag), (EventDataFilter)(insertCommand.updateDataFilter != -1 ? (int)insertCommand.updateDataFilter : (int)EventDataFilter.None), (EventDataFilter)(insertCommand.removeDataFilter != -1 ? (int)insertCommand.removeDataFilter : (int)EventDataFilter.None) ); cmdInfo.Entries[index].Value = cbEntry.Clone(); } 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.Entries[index].QueryInfo = queryInfo; index++; } break; } return cmdInfo; }