/// <summary> /// Cleans up the current batch. /// </summary> public void Cleanup() { _putBatch = null; _currentBatch = null; _currentPersister = null; }
/// <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); }
private bool ShouldExecuteBatch(ICollectionPersister persister, AbstractCacheBatch batch) { return(batch != _currentBatch || _currentPersister != persister || _currentBatch.BatchSize >= persister.GetBatchSize()); }