示例#1
0
        /// <summary>
        /// Cleans up the current batch.
        /// </summary>
        public void Cleanup()
        {
            _putBatch = null;

            _currentBatch     = null;
            _currentPersister = null;
        }
        private void AddToBatch(ICacheConcurrencyStrategy cache, CachePutData data)
        {
            if (!_putBatches.TryGetValue(cache, out var cachePutBatch))
            {
                cachePutBatch = new CachePutBatch(_session, cache);
                _putBatches.Add(cache, cachePutBatch);
            }

            cachePutBatch.Add(data);
        }
示例#3
0
 /// <summary>
 /// Adds a put operation to the batch. If the batch size reached the persister batch
 /// size, the batch will be executed.
 /// </summary>
 /// <param name="persister">The collection persister.</param>
 /// <param name="data">The data to put in the cache.</param>
 public void AddToBatch(ICollectionPersister persister, CachePutData data)
 {
     if (ShouldExecuteBatch(persister, _putBatch))
     {
         ExecuteBatch();
         _currentPersister = persister;
         _currentBatch     = _putBatch = new CachePutBatch(_session, persister.Cache);
     }
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Adding a put operation to batch for collection role {0} and key {1}", persister.Role, data.Key);
     }
     _putBatch.Add(data);
 }
示例#4
0
 /// <summary>
 /// Adds a put operation to the batch. If the batch size reached the persister batch
 /// size, the batch will be executed.
 /// </summary>
 /// <param name="persister">The collection persister.</param>
 /// <param name="data">The data to put in the cache.</param>
 /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
 public async Task AddToBatchAsync(ICollectionPersister persister, CachePutData data, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     if (ShouldExecuteBatch(persister, _putBatch))
     {
         await(ExecuteBatchAsync(cancellationToken)).ConfigureAwait(false);
         _currentPersister = persister;
         _currentBatch     = _putBatch = new CachePutBatch(_session, persister.Cache);
     }
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Adding a put operation to batch for collection role {0} and key {1}", persister.Role, data.Key);
     }
     _putBatch.Add(data);
 }