class Synapse::EventSourcing::CacheClearingUnitOfWorkListener

Listener that removes an aggregate from the cache if the unit of work is rolled back @api private

Public Class Methods

new(aggregate_id, cache) click to toggle source

@param [Object] aggregate_id @param [ActiveSupport::Cache::Store] cache @return [undefined]

# File lib/synapse/event_sourcing/caching.rb, line 53
def initialize(aggregate_id, cache)
  @aggregate_id = aggregate_id
  @cache = cache
end

Public Instance Methods

on_rollback(unit, cause = nil) click to toggle source

@param [UnitOfWork] unit @param [Error] cause @return [undefined]

# File lib/synapse/event_sourcing/caching.rb, line 61
def on_rollback(unit, cause = nil)
  @cache.delete @aggregate_id
end