Пример #1
0
        protected void BatchMessage(
            IEnumerable <IServerAddress> servers,
            ICacheRefresher refresher,
            MessageType messageType,
            IEnumerable <object> ids = null,
            Type idType = null,
            string json = null)
        {
            var batch        = GetBatch(true);
            var instructions = RefreshInstruction.GetInstructions(refresher, messageType, ids, idType, json);

            // batch if we can, else write to DB immediately
            if (batch == null)
            {
                //only write the json blob with a maximum count of the MaxProcessingInstructionCount
                using (var scope = _appContext.ScopeProvider.CreateScope())
                {
                    foreach (var maxBatch in instructions.InGroupsOf(Options.MaxProcessingInstructionCount))
                    {
                        WriteInstructions(scope, maxBatch);
                    }
                    scope.Complete();
                }
            }
            else
            {
                batch.Add(new RefreshInstructionEnvelope(servers, refresher, instructions));
            }
        }
        protected override void DeliverRemote(
            ICacheRefresher refresher,
            MessageType messageType,
            IEnumerable <object> ids = null,
            string json = null)
        {
            var idsA = ids?.ToArray();

            if (GetArrayType(idsA, out Type idType) == false)
            {
                throw new ArgumentException("All items must be of the same type, either int or Guid.", nameof(ids));
            }

            IEnumerable <RefreshInstruction> instructions = RefreshInstruction.GetInstructions(refresher, JsonSerializer, messageType, idsA, idType, json);

            CacheInstructionService.DeliverInstructions(instructions, LocalIdentity);
        }
        private void BatchMessage(
            ICacheRefresher refresher,
            MessageType messageType,
            IEnumerable <object> ids = null,
            Type idType = null,
            string json = null)
        {
            ICollection <RefreshInstructionEnvelope> batch        = GetBatch(true);
            IEnumerable <RefreshInstruction>         instructions = RefreshInstruction.GetInstructions(refresher, JsonSerializer, messageType, ids, idType, json);

            // Batch if we can, else write to DB immediately.
            if (batch == null)
            {
                CacheInstructionService.DeliverInstructionsInBatches(instructions, LocalIdentity);
            }
            else
            {
                batch.Add(new RefreshInstructionEnvelope(refresher, instructions));
            }
        }
Пример #4
0
        protected void BatchMessage(
            IEnumerable <IServerAddress> servers,
            ICacheRefresher refresher,
            MessageType messageType,
            IEnumerable <object> ids = null,
            Type idType = null,
            string json = null)
        {
            var batch        = GetBatch(true);
            var instructions = RefreshInstruction.GetInstructions(refresher, messageType, ids, idType, json);

            // batch if we can, else write to DB immediately
            if (batch == null)
            {
                WriteInstructions(instructions.ToArray());
            }
            else
            {
                batch.Add(new RefreshInstructionEnvelope(servers, refresher, instructions));
            }
        }