Added a routine that will cache stuff that costs a lot of queries.

This commit is contained in:
James Cole
2014-11-25 22:04:50 +01:00
parent 6e19bc01f5
commit 114b27079e
5 changed files with 88 additions and 8 deletions

View 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');
}
}