mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Added a routine that will cache stuff that costs a lot of queries.
This commit is contained in:
38
app/lib/FireflyIII/Event/Transaction.php
Normal file
38
app/lib/FireflyIII/Event/Transaction.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Event;
|
||||
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
class Transaction
|
||||
{
|
||||
public function destroy(\Transaction $transaction)
|
||||
{
|
||||
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
|
||||
\Cache::forget('account.' . $transaction->account_id . '.lastActivityDate');
|
||||
}
|
||||
|
||||
public function store(\Transaction $transaction)
|
||||
{
|
||||
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
|
||||
\Cache::forget('account.' . $transaction->account_id . '.lastActivityDate');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
// triggers when others are updated.
|
||||
$events->listen('transaction.store', 'FireflyIII\Event\Transaction@store');
|
||||
$events->listen('transaction.update', 'FireflyIII\Event\Transaction@update');
|
||||
$events->listen('transaction.destroy', 'FireflyIII\Event\Transaction@destroy');
|
||||
}
|
||||
|
||||
public function update(\Transaction $transaction)
|
||||
{
|
||||
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
|
||||
\Cache::forget('account.' . $transaction->account_id . '.lastActivityDate');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user