Class: Synapse::EventSourcing::CacheClearingUnitOfWorkListener Private

Inherits:
UnitOfWork::UnitOfWorkListener show all
Defined in:
lib/synapse/event_sourcing/caching.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

Instance Method Summary collapse

Methods inherited from UnitOfWork::UnitOfWorkListener

#after_commit, #on_cleanup, #on_event_registered, #on_prepare_commit, #on_prepare_transaction_commit, #on_start

Constructor Details

#initialize(aggregate_id, cache) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • aggregate_id (Object)
  • cache (ActiveSupport::Cache::Store)


53
54
55
56
# File 'lib/synapse/event_sourcing/caching.rb', line 53

def initialize(aggregate_id, cache)
  @aggregate_id = aggregate_id
  @cache = cache
end

Instance Method Details

#on_rollback(unit, cause = nil) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • unit (UnitOfWork)
  • cause (Error) (defaults to: nil)

Returns:

  • (undefined)


61
62
63
# File 'lib/synapse/event_sourcing/caching.rb', line 61

def on_rollback(unit, cause = nil)
  @cache.delete @aggregate_id
end