//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); return; } //TODO try { NCache nCache = clientManager.CmdExecuter as NCache; ClusteredList <ReaderResultSet> resultSetList = null; Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); //client id operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); resultSetList = nCache.Cache.ExecuteReader(cmdInfo.Query, cmdInfo.Values, cmdInfo.GetData, cmdInfo.ChunkSize, false, operationContext); ReaderResponseBuilder.Cache = nCache.Cache; ReaderResponseBuilder.BuildExecuteReaderResponse(resultSetList, cmdInfo.RequestId, _serializedResponsePackets); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; ClientId = clientManager.ClientID; //Asif Imam NCache nCache = clientManager.CmdExecuter as NCache; try { serailizationContext = nCache.CacheId; cmdInfo = base.ParseCommand(command, clientManager, serailizationContext); if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("BulkInsCmd.Exec", "cmd parsed"); } catch (Exception exc) { _insertBulkResult = OperationResult.Failure; //if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } //TODO byte[] dataPackage = null; try { OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient)) operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient); Hashtable insertResult = (Hashtable)nCache.Cache.Insert(cmdInfo.Keys, cmdInfo.Values, cmdInfo.CallbackEnteries, cmdInfo.ExpirationHint, cmdInfo.EvictionHint, cmdInfo.QueryInfo, cmdInfo.Flags, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkInsertResponse bulkInsertResponse = new Alachisoft.NCache.Common.Protobuf.BulkInsertResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.intendedRecipient = cmdInfo.IntendedRecipient; bulkInsertResponse.keyExceptionPackage = new Alachisoft.NCache.Common.Protobuf.KeyExceptionPackageResponse(); //TODO : Package Key Value Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysExceptions(insertResult, bulkInsertResponse.keyExceptionPackage); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.INSERT_BULK; response.bulkInsert = bulkInsertResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _insertBulkResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("BulkInsCmd.Exec", "cmd executed on cache"); }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID)); return; } int resultCount = 0; try { NCache nCache = clientManager.CmdExecuter as NCache; Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); if (cmdInfo.CommandVersion <= 1) //NCache 3.8 SP4 and previous { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else { operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); } resultSet = nCache.Cache.Search(cmdInfo.Query, cmdInfo.Values, operationContext); stopWatch.Stop(); SearchResponseBuilder.BuildResponse(resultSet, cmdInfo.RequestId, command.commandID, _serializedResponsePackets, cmdInfo.CommandVersion, out resultCount); } catch (Exception exc) { exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.Search.ToLower()); log.GenerateSearchAPILogItem(cmdInfo.Query, cmdInfo.Values, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resultCount); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID)); return; } int resultCount = 0; try { NCache nCache = clientManager.CmdExecuter as NCache; ClusteredList <ReaderResultSet> resultSetList = null; Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); //client id operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID); resultSetList = nCache.Cache.ExecuteReader(cmdInfo.Query, cmdInfo.Values, cmdInfo.GetData, cmdInfo.ChunkSize, false, operationContext); stopWatch.Stop(); ReaderResponseBuilder.Cache = nCache.Cache; ReaderResponseBuilder.BuildExecuteReaderResponse(resultSetList, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, clientManager.ClientVersion < 4620, out resultCount); } catch (Exception exc) { //PROTOBUF:RESPONSE exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.ExecuteReader.ToLower()); log.GenerateExecuteReaderAPILogItem(cmdInfo.Query, cmdInfo.Values, cmdInfo.GetData, cmdInfo.ChunkSize, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resultCount); } } catch { } } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } //TODO byte[] data = null; try { NCache nCache = clientManager.CmdExecuter as NCache; CallbackEntry cbEnrty = null; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient)) operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient); nCache.Cache.Delete(cmdInfo.Keys, cmdInfo.FlagMap, cbEnrty, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.BulkDeleteResponse bulkDeleteResponse = new Alachisoft.NCache.Common.Protobuf.BulkDeleteResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.intendedRecipient = cmdInfo.IntendedRecipient; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.DELETE_BULK; response.bulkDeleteResponse = bulkDeleteResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); return; } NCache nCache = clientManager.CmdExecuter as NCache; try { object lockId = cmdInfo.LockId; DateTime lockDate = new DateTime(); OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true); CacheEntry entry = (CacheEntry)nCache.Cache.GetCacheEntry(cmdInfo.Key, ref lockId, ref lockDate, cmdInfo.LockTimeout, cmdInfo.LockAccessType, operationContext); Alachisoft.NCache.Common.Protobuf.GetCacheItemResponse getCacheItemResponse = new Alachisoft.NCache.Common.Protobuf.GetCacheItemResponse(); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_CACHE_ITEM; if (entry == null) { getCacheItemResponse.lockId = lockId == null ? string.Empty : lockId.ToString(); getCacheItemResponse.lockTicks = lockDate.Ticks; response.getItem = getCacheItemResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); return; } getCacheItemResponse = PopulateResponse(entry, getCacheItemResponse, clientManager); response.getItem = getCacheItemResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("RemCmd.Exec", "cmd parsed"); } catch (Exception exc) { _removeResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } NCache nCache = clientManager.CmdExecuter as NCache; try { CallbackEntry cbEntry = null; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); nCache.Cache.Delete(cmdInfo.Key, cmdInfo.FlagMap, cbEntry, cmdInfo.LockId, cmdInfo.LockAccessType, operationContext); //PROTOBUF:RESPONSE Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.DeleteResponse removeResponse = new Alachisoft.NCache.Common.Protobuf.DeleteResponse(); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.DELETE; response.deleteResponse = removeResponse; response.requestId = Convert.ToInt64(cmdInfo.RequestId); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _removeResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add( Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } finally { if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("RemCmd.Exec", "cmd executed on cache"); } }
private static char Delimitor = '|'; //Asif Imam public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; QueryResultSet resultSet = null; Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); if (cmdInfo.CommandVersion <= 1) //NCache 3.8 SP4 and previous { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 SP1 or later { operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); } resultSet = nCache.Cache.Search(cmdInfo.Query, cmdInfo.Values, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); response.search = SearchResponseBuilder.BuildResponse(resultSet, cmdInfo.CommandVersion); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.SEARCH; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
private static char Delimitor = '|'; //Asif Imam public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; QueryResultSet resultSet = null; Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); if (cmdInfo.CommandVersion <= 1) //NCache 3.8 SP4 and previous { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 SP1 or later { operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); } resultSet = nCache.Cache.Search(cmdInfo.Query, cmdInfo.Values, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); response.search = SearchResponseBuilder.BuildResponse(resultSet, cmdInfo.CommandVersion); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.SEARCH; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("BulkGetCmd.Exec", "cmd parsed"); } catch (Exception exc) { _getBulkResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } byte[] data = null; NCache nCache = clientManager.CmdExecuter as NCache; try { OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); if (!string.IsNullOrEmpty(cmdInfo.IntendedRecipient)) operationContext.Add(OperationContextFieldName.IntendedRecipient, cmdInfo.IntendedRecipient); Hashtable getResult = (Hashtable)nCache.Cache.GetBulk(cmdInfo.Keys, cmdInfo.FlagMap, operationContext); BulkGetResponseBuilder.BuildResponse(getResult, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, cmdInfo.IntendedRecipient); } catch (Exception exc) { _getBulkResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("BulkGetCmd.Exec", "cmd executed on cache"); }
public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } //TODO byte[] data = null; try { NCache nCache = clientManager.CmdExecuter as NCache; CallbackEntry cbEnrty = null; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); Hashtable removeResult = (Hashtable)nCache.Cache.Remove(cmdInfo.Keys, cmdInfo.FlagMap, cbEnrty, operationContext); BulkRemoveResponseBuilder.BuildResponse(removeResult, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets); } catch (Exception exc) { _removeBulkResult = OperationResult.Failure; //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } NCache nCache = clientManager.CmdExecuter as NCache; try { CallbackEntry cbEntry = null; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); nCache.Cache.Clear(cmdInfo.FlagMap, cbEntry, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.ClearResponse clearResponse = new Alachisoft.NCache.Common.Protobuf.ClearResponse(); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.CLEAR; response.clearResponse = clearResponse; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
/// <summary> /// Removes the objects from the <see cref="Cache"/>. /// </summary> /// <param name="keys">The cache keys used to reference the item.</param> /// <param name="flagMap"></param> /// <returns>The items removed from the Cache. If the value in the keys parameter /// is not found, returns a null reference (Nothing in Visual Basic).</returns> /// <exception cref="ArgumentNullException"><paramref name="keys"/> contains a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentException"><paramref name="keys"/> is not serializable.</exception> /// <remarks> /// <para><b>Note:</b> If exceptions are enabled through the <see cref="NCache.ExceptionsEnabled"/> /// setting, this property throws exception incase of failure.</para> /// </remarks> /// <example>The following example demonstrates how you can remove an item from your application's /// <see cref="Cache"/> object. /// <code> /// /// NCache.Cache.Remove(keys); /// /// </code> /// Or simply in a class deriving from <see cref="Alachisoft.NCache.Web.UI.NPage"/> or <see cref="Alachisoft.NCache.Web.UI.NUserControl"/>. /// <code> /// /// Cache.Remove(keys); /// /// </code> /// </example> public override IDictionary Remove(string[] keys, BitSet flagMap) { CallbackEntry cbEntry = null; object[] baseKeys = new object[keys.Length]; for (int i = 0; i < keys.Length; i++) baseKeys[i] = keys[i]; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); IDictionary items = _nCache.Remove(baseKeys, flagMap, cbEntry, operationContext); if (items != null) { IDictionaryEnumerator ide = items.GetEnumerator(); while (ide.MoveNext()) { CompressedValueEntry cmpEntry = ide.Value as CompressedValueEntry; if (cmpEntry != null && cmpEntry.Value != null) { if (cmpEntry.Value is UserBinaryObject) { UserBinaryObject ubObject = cmpEntry.Value as UserBinaryObject; cmpEntry.Value = ubObject.GetFullObject(); } } } } return items; }
//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> /// Removes the object from the <see cref="Cache"/>. /// </summary> /// <param name="key">The cache key used to reference the item.</param> /// <exception cref="ArgumentNullException"><paramref name="key"/> contains a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentException"><paramref name="key"/> is not serializable.</exception> /// <remarks> /// <para><b>Note:</b> If exceptions are enabled through the <see cref="NCache.ExceptionsEnabled"/> /// setting, this property throws exception incase of failure.</para> /// </remarks> /// <example>The following example demonstrates how you can remove an item from your application's /// <see cref="Cache"/> object. /// <code> /// /// NCache.Cache.Remove("timestamp"); /// /// </code> /// Or simply in a class deriving from <see cref="Alachisoft.NCache.Web.UI.NPage"/> or <see cref="Alachisoft.NCache.Web.UI.NUserControl"/>. /// <code> /// /// Cache.Remove("timestamp"); /// /// </code> /// </example> public override void Delete(string key, BitSet flagMap, object lockId, LockAccessType accessType) { if (_nCache != null) { OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); _nCache.Delete(key, flagMap, null, lockId, accessType, operationContext); } }
internal CacheEntry CascadedRemove(object key, object pack, ItemRemoveReason reason, bool notify, object lockId, LockAccessType accessType, OperationContext operationContext) { CacheEntry oldEntry = _context.CacheImpl.Remove(pack, reason, notify, lockId, accessType, operationContext); return oldEntry; }
public override object GetCacheItem(string key, BitSet flagMap, ref LockHandle lockHandle, TimeSpan lockTimeout, LockAccessType accessType) { if (lockHandle == null) lockHandle = new LockHandle(); object lockId = lockHandle.LockId; DateTime lockDate = new DateTime(); OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true); CacheEntry entry = _nCache.GetCacheEntry(key, ref lockId, ref lockDate, lockTimeout, accessType, operationContext) as CacheEntry; if (entry != null) { if (entry.Value is CallbackEntry) { CallbackEntry cbEntry = entry.Value as CallbackEntry; if (cbEntry.Value is UserBinaryObject) { cbEntry.Value = ((UserBinaryObject)cbEntry.Value).GetFullObject(); } } else { if (entry.Value is UserBinaryObject) { entry.Value = ((UserBinaryObject)entry.Value).GetFullObject(); } } } lockHandle.LockId = lockId == null ? null : lockId as string; lockHandle.LockDate = lockDate; return entry; }
/// <summary> Insert list of <see cref="CacheItem"/> to the cache </summary> /// <param name="keys">The cache keys used to reference the items.</param> /// <param name="items">The items that are to be stored</param> /// <returns>returns keys that are added or updated successfully and their status.</returns> /// <remarks> If CacheItem contains invalid values the related exception is thrown. /// See <see cref="CacheItem"/> for invalid property values and related exceptions</remarks> /// <example>The following example demonstrates how to assign an item high priority when you insert /// it into your application's <see cref="Cache"/> object. /// <para><b>Note: </b>For more information about how to use this method with the <see cref="CacheItemRemovedCallback"/> /// delegate, see <see cref="CacheItemRemovedCallback"/>. /// </para> /// First create CacheItems. /// <code> /// string[] keys = {"SQLDSN", "ORADSN"}; /// CacheItem items[] = new CacheItem[2]; /// items[0] = new CacheItem(sqlConnectionString); /// item.AbsoluteExpiration = DateTime.Now.AddMinutes(2); /// item.SlidingExpiration = TimeSpan.Zero; /// item.Priority = CacheItemPriority.High; /// item.ItemRemoveCallback = onRemove; /// /// items[1] = new CacheItem(oraConnectionString); /// item.AbsoluteExpiration = DateTime.Now.AddMinutes(1); /// item.SlidingExpiration = TimeSpan.Zero; /// item.Priority = CacheItemPriority.Low; /// item.ItemRemoveCallback = onRemove; /// </code> /// /// Then insert CacheItems to the cache /// <code> /// /// NCache.Cache.Insert(keys, items); /// /// </code> /// Or simply in a class deriving from <see cref="Alachisoft.NCache.Web.UI.NPage"/> or <see cref="Alachisoft.NCache.Web.UI.NUserControl"/>. /// <code> /// /// Cache.Insert(keys, items); /// /// </code> /// </example> public override IDictionary Insert(string[] keys, CacheItem[] items, long[] sizes) { if (_nCache == null) return null; object[] entries = new object[items.Length]; ExpirationHint hint = null; short itemRemovedCallback = -1; short itemUpdatedCallback = -1; for (int i = 0; i < items.Length; i++) { string key = keys[i]; CacheItem item = items[i]; itemRemovedCallback = -1; itemUpdatedCallback = -1; if (item.CacheItemRemovedCallback != null) { short[] callabackIds = _parent.EventManager.RegisterSelectiveEvent(item.CacheItemRemovedCallback, EventType.ItemRemoved, item.ItemRemovedCallabackDataFilter); itemRemovedCallback = callabackIds[1]; } if (item.CacheItemUpdatedCallback != null) { short[] callabackIds = _parent.EventManager.RegisterSelectiveEvent(item.CacheItemUpdatedCallback, EventType.ItemUpdated, item.ItemUpdatedCallabackDataFilter); itemUpdatedCallback = callabackIds[0]; } Hashtable queryInfoDic = item.QueryInfo["query-info"] as Hashtable; if (queryInfoDic != null) { IDictionaryEnumerator queryInfoEnum = queryInfoDic.GetEnumerator(); while (queryInfoEnum.MoveNext()) { ArrayList valuesEnum = (ArrayList)queryInfoEnum.Value; for (int j = 0; j < valuesEnum.Count; j++) { if (valuesEnum[j] is DateTime) { valuesEnum[j] = ((DateTime)valuesEnum[j]).Ticks.ToString(); } } } } entries[i] = MakeCompactEntry(key, item.Value, item.AbsoluteExpiration, item.SlidingExpiration, item.Priority, itemRemovedCallback, itemRemovedCallback, item.QueryInfo, item.FlagMap, null, LockAccessType.IGNORE_LOCK, item.ItemUpdatedCallabackDataFilter, item.ItemRemovedCallabackDataFilter); } OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ValueDataSize, sizes); return _nCache.InsertEntries(entries, operationContext); }
public EnumerationDataChunk GetNextChunk(EnumerationPointer pointer, OperationContext operationContext) { EnumerationDataChunk chunk = null; if (!IsRunning) return null; try { chunk = _context.CacheImpl.GetNextChunk(pointer, operationContext); } catch (Exception inner) { _context.NCacheLog.Error("Cache.GetNextChunk()", inner.ToString()); throw new OperationFailedException("GetNextChunk failed. Error : " + inner.Message, inner); } return chunk; }
/// <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); } }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID)); } return; } byte[] data = null; int resultCount = 0; try { NCache nCache = clientManager.CmdExecuter as NCache; QueryResultSet resultSet = null; QueryDataFilters datafilters = new QueryDataFilters(cmdInfo.addDF, cmdInfo.updateDF, cmdInfo.removeDF); Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); if (Convert.ToInt64(cmdInfo.ClientLastViewId) != -1) { operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); } operationContext.Add(OperationContextFieldName.ClientOperationTimeout, clientManager.RequestTimeout); operationContext.CancellationToken = CancellationToken; resultSet = nCache.Cache.SearchEntriesCQ(cmdInfo.Query, cmdInfo.Values, cmdInfo.clientUniqueId, clientManager.ClientID, cmdInfo.notifyAdd, cmdInfo.notifyUpdate, cmdInfo.notifyRemove, operationContext, datafilters); stopWatch.Stop(); SearchEnteriesCQResponseBuilder.BuildResponse(resultSet, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, nCache.Cache, out resultCount); } catch (OperationCanceledException ex) { exception = ex.ToString(); Dispose(); } catch (Exception exc) { exception = exc.ToString(); //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID)); } finally { TimeSpan executionTime = stopWatch.Elapsed; try { if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging) { APILogItemBuilder log = new APILogItemBuilder(MethodsName.SearchCQ.ToLower()); log.GenerateSearchEntriesCQAPILogItem(cmdInfo.Query, cmdInfo.Values, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resultCount); } } catch { } } }
internal CacheInsResultWithEntry CascadedInsert(object key, CacheEntry entry, bool notify, object lockId, LockAccessType accessType, OperationContext operationContext) { CacheInsResultWithEntry result = _context.CacheImpl.Insert(key, entry, notify, lockId, accessType, operationContext); return result; }
internal void UnregisterKeyNotificationCallback(string[] keys, CallbackInfo updateCallback, CallbackInfo removeCallback, OperationContext operationContext) { if (!IsRunning) return; if (keys == null) throw new ArgumentNullException("keys"); if (keys.Length == 0) throw new ArgumentException("Keys count can not be zero"); if (updateCallback == null && removeCallback == null) throw new ArgumentNullException(); try { _context.CacheImpl.UnregisterKeyNotification(keys, updateCallback, removeCallback, operationContext); } catch (OperationFailedException inner) { if (inner.IsTracable) _context.NCacheLog.Error("Cache.UnregisterKeyNotificationCallback() ", inner.ToString()); throw; } catch (Exception inner) { _context.NCacheLog.Error("Cache.UnregisterKeyNotificationCallback()", inner.ToString()); throw new OperationFailedException("UnregisterKeyNotification failed. Error : " + inner.Message, inner); } }
/// <summary> /// Registers the item update/remove or both callbacks with the specified key. /// Keys should exist before the registration. /// </summary> /// <param name="key"></param> /// <param name="updateCallback"></param> /// <param name="removeCallback"></param> public void RegisterKeyNotificationCallback(string key, CallbackInfo updateCallback, CallbackInfo removeCallback, OperationContext operationContext) { if (!IsRunning) return; if (key == null) throw new ArgumentNullException("key"); if (updateCallback == null && removeCallback == null) throw new ArgumentNullException(); try { _context.CacheImpl.RegisterKeyNotification(key, updateCallback, removeCallback, operationContext); } catch (OperationFailedException inner) { if (inner.IsTracable) _context.NCacheLog.Error("Cache.RegisterKeyNotificationCallback() ", inner.ToString()); throw; } catch (Exception inner) { _context.NCacheLog.Error("Cache.RegisterKeyNotificationCallback() ", inner.ToString()); throw new OperationFailedException("RegisterKeyNotification failed. Error : " + inner.Message, inner); } }
internal Hashtable CascadedRemove(IList keys, ItemRemoveReason reason, bool notify, OperationContext operationContext) { Hashtable table = _context.CacheImpl.Remove(keys, reason, notify, operationContext); return table; }
public override void Delete(string[] keys, BitSet flagMap) { CallbackEntry cbEntry = null; object[] baseKeys = new object[keys.Length]; for (int i = 0; i < keys.Length; i++) baseKeys[i] = keys[i]; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); _nCache.Delete(baseKeys, flagMap, cbEntry, operationContext); }
public object Clone() { OperationContext oc = new OperationContext(); lock (this) { if (_fieldValueTable != null) { if (oc._fieldValueTable != null) oc._fieldValueTable.Clear(); else oc._fieldValueTable = new Hashtable(); IDictionaryEnumerator ide = _fieldValueTable.GetEnumerator(); while (ide.MoveNext()) { Object clone = ide.Value is ICloneable ? ((ICloneable)ide.Value).Clone() : ide.Value; oc._fieldValueTable.Add(ide.Key, clone); } } } return oc; }
/// <summary> /// Removes all elements from the <see cref="Cache"/>. /// </summary> /// <remarks>In most of the cases this method's implementation is close to O(1). /// <para><b>Note:</b> If exceptions are enabled through the <see cref="NCache.ExceptionsEnabled"/> /// setting, this property throws exception incase of failure.</para> /// </remarks> /// <example>The following example demonstrates how to check for containment of an item in the <see cref="Cache"/>. /// <code> /// /// NCache.Cache.Clear(); /// /// </code> /// Or simply in a class deriving from <see cref="Alachisoft.NCache.Web.UI.NPage"/> or <see cref="Alachisoft.NCache.Web.UI.NUserControl"/>. /// <code> /// /// Cache.Clear(); /// /// </code> /// </example> public override void Clear(BitSet flagMap) { if (_nCache == null) return; CallbackEntry cbEntry = null; OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); _nCache.Clear(flagMap, cbEntry, operationContext); }
/// <summary> /// Fired when an item is updated and it has CacheItemUpdate callback attached with it. /// </summary> /// <param name="key">key of the cache item</param> /// <param name="value">CallbackEntry containing the callback and actual item</param> void ICacheEventsListener.OnCustomUpdateCallback(object key, object value, OperationContext operationContext, EventContext eventContext) { ArrayList updateListeners = value as ArrayList; if (updateListeners != null && updateListeners.Count > 0) { updateListeners = updateListeners.Clone() as ArrayList; foreach (CallbackInfo cbInfo in updateListeners) { if (_connectedClients != null && _connectedClients.Contains(cbInfo.Client)) { if (_customUpdateNotif != null) { Delegate[] dltList = _customUpdateNotif.GetInvocationList(); for (int i = dltList.Length - 1; i >= 0; i--) { CustomUpdateCallback subscriber = (CustomUpdateCallback)dltList[i]; try { subscriber.BeginInvoke(key, cbInfo, eventContext, new System.AsyncCallback(CustomUpdateAsyncCallbackHandler), subscriber); } catch (System.Net.Sockets.SocketException e) { _context.NCacheLog.Error("Cache.OnCustomUpdateCallback()", e.ToString()); _customUpdateNotif -= subscriber; } catch (Exception e) { _context.NCacheLog.Error("Cache.OnCustomUpdateCallback", e.ToString()); } } } } } } }
/// <summary> /// Function that choose the appropriate function of NCache's Cache, that need to be called /// according to the data provided to it.</summary> public override void Insert(string key, object value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, short onRemoveCallback, short onUpdateCallback, Hashtable queryInfo, BitSet flagMap, object lockId,LockAccessType accessType, EventDataFilter updateCallbackFilter, EventDataFilter removeCallabackFilter, long size) { Hashtable queryInfoDic = queryInfo["query-info"] as Hashtable; if (queryInfoDic != null) { IDictionaryEnumerator queryInfoEnum = queryInfoDic.GetEnumerator(); while (queryInfoEnum.MoveNext()) { ArrayList valuesEnum = (ArrayList)queryInfoEnum.Value; for (int i = 0; i < valuesEnum.Count; i++) { if (valuesEnum[i] is DateTime) { valuesEnum[i] = ((DateTime)valuesEnum[i]).Ticks.ToString(); } } } } object entry = MakeCompactEntry(key, value, absoluteExpiration, slidingExpiration, priority, onRemoveCallback, onUpdateCallback, queryInfo, flagMap, lockId, accessType, updateCallbackFilter, removeCallabackFilter); OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); operationContext.Add(OperationContextFieldName.ValueDataSize, size); _nCache.InsertEntry(entry, operationContext); }
/// <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 object from the <see cref="Cache"/>. /// </summary> /// <param name="key">The cache key used to reference the item.</param> /// <returns>The item removed from the Cache. If the value in the key parameter /// is not found, returns a null reference (Nothing in Visual Basic).</returns> /// <exception cref="ArgumentNullException"><paramref name="key"/> contains a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentException"><paramref name="key"/> is not serializable.</exception> /// <remarks> /// <para><b>Note:</b> If exceptions are enabled through the <see cref="NCache.ExceptionsEnabled"/> /// setting, this property throws exception incase of failure.</para> /// </remarks> /// <example>The following example demonstrates how you can remove an item from your application's /// <see cref="Cache"/> object. /// <code> /// /// NCache.Cache.Remove("timestamp"); /// /// </code> /// Or simply in a class deriving from <see cref="Alachisoft.NCache.Web.UI.NPage"/> or <see cref="Alachisoft.NCache.Web.UI.NUserControl"/>. /// <code> /// /// Cache.Remove("timestamp"); /// /// </code> /// </example> public override CompressedValueEntry Remove(string key, BitSet flagMap, object lockId, LockAccessType accessType) { if (_nCache != null) { OperationContext operationContext = new OperationContext(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation); CompressedValueEntry cmpEntry = _nCache.Remove(key, flagMap, null, lockId, accessType, operationContext); if (cmpEntry != null && cmpEntry.Value != null) { if (cmpEntry.Value is UserBinaryObject) { UserBinaryObject ubObject = cmpEntry.Value as UserBinaryObject; cmpEntry.Value = ubObject.GetFullObject(); } } return cmpEntry; } return null; }
public QueryResultSet SearchEntries(string query, IDictionary values, OperationContext operationContext) { if (!IsRunning) return null; if (query == null || query == String.Empty) throw new ArgumentNullException("query"); try { return _context.CacheImpl.SearchEntries(query, values, operationContext); } catch (OperationFailedException ex) { if (ex.IsTracable) { if (_context.NCacheLog.IsErrorEnabled) _context.NCacheLog.Error("search operation failed. Error: " + ex.ToString()); } throw; } catch (StateTransferInProgressException inner) { throw; } catch (Exception ex) { if (_context.NCacheLog.IsErrorEnabled) _context.NCacheLog.Error("search operation failed. Error: " + ex.ToString()); if (ex is Alachisoft.NCache.Parser.TypeIndexNotDefined) throw new Runtime.Exceptions.TypeIndexNotDefined("search operation failed. Error: " + ex.Message, ex); if (ex is Alachisoft.NCache.Parser.AttributeIndexNotDefined) throw new Runtime.Exceptions.AttributeIndexNotDefined("search operation failed. Error: " + ex.Message, ex); throw new OperationFailedException("search operation failed. Error: " + ex.Message, ex); } }
/// <summary> /// Fired when an item is removed from the cache having CacheItemRemoveCallback. /// </summary> /// <param name="key">key of the cache item</param> /// <param name="value">CallbackEntry containing the callback and actual item</param> /// <param name="reason">reason the item was removed</param> void ICacheEventsListener.OnCustomRemoveCallback(object key, object value, ItemRemoveReason reason, OperationContext operationContext, EventContext eventContext) { CallbackEntry cbEntry = value as CallbackEntry; ArrayList removeCallbacklist = eventContext.GetValueByField(EventContextFieldName.ItemRemoveCallbackList) as ArrayList; if (removeCallbacklist != null && removeCallbacklist.Count > 0) { foreach (CallbackInfo cbInfo in removeCallbacklist) { if (reason == ItemRemoveReason.Expired && cbInfo != null && !cbInfo.NotifyOnExpiration) continue; if (_connectedClients != null && _connectedClients.Contains(cbInfo.Client)) { if (_customRemoveNotif != null) { Delegate[] dltList = _customRemoveNotif.GetInvocationList(); for (int i = dltList.Length - 1; i >= 0; i--) { CustomRemoveCallback subscriber = (CustomRemoveCallback)dltList[i]; try { subscriber.BeginInvoke(key, new object[] { null, cbInfo }, reason, null, eventContext, new System.AsyncCallback(CustomRemoveAsyncCallbackHandler), subscriber); } catch (System.Net.Sockets.SocketException e) { _context.NCacheLog.Error("Cache.OnCustomRemoveCallback()", e.ToString()); _customRemoveNotif -= subscriber; } catch (Exception e) { _context.NCacheLog.Error("Cache.OnCustomRemoveCallback", e.ToString()); } } } } } } }
internal Hashtable CascadedInsert(object[] keys, CacheEntry[] cacheEntries, bool notify, OperationContext operationContext) { Hashtable table = _context.CacheImpl.Insert(keys, cacheEntries, notify, operationContext); return table; }