Aggregation Queue

ReactionCounter & ReactionTotal aggregates updates synchronously when you have QUEUE_CONNECTION=sync defined in .env file. On large databases this operations are expensive and could lead to long wait time and browser hanging connection.

There are 2 listeners which are responsible for aggregates updates:

  • Cog\Laravel\Love\Reactant\Listeners\IncrementAggregates
  • Cog\Laravel\Love\Reactant\Listeners\DecrementAggregates

IncrementAggregates listener awaits for the ReactionHasBeenAdded event being dispatched and runs async job Cog\Laravel\Love\Reactant\Jobs\IncrementReactionAggregatesJob.

DecrementAggregates listener awaits for the ReactionHasBeenRemoved event being dispatched and runs async job Cog\Laravel\Love\Reactant\Jobs\DecrementReactionAggregatesJob.

Setup queue connection in your application and updates will be executed on background.