Extra cache.

This commit is contained in:
James Cole 2015-12-25 17:11:55 +01:00
parent 72d054c55c
commit 9f7c6c2d0c
2 changed files with 24 additions and 5 deletions

View File

@ -41,7 +41,16 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function countAccounts(array $types)
{
return Auth::user()->accounts()->accountTypeIn($types)->count();
$cache = new CacheProperties;
$cache->addProperty('user-count-accounts');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$count = Auth::user()->accounts()->accountTypeIn($types)->count();
$cache->store($count);
return $count;
}
/**
@ -123,8 +132,7 @@ class AccountRepository implements AccountRepositoryInterface
public function getFrontpageAccounts(Preference $preference)
{
$cache = new CacheProperties();
$cache->addProperty($preference->data);
$cache->addProperty('frontPageaccounts');
$cache->addProperty('user-frontpage-accounts');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
@ -229,7 +237,7 @@ class AccountRepository implements AccountRepositoryInterface
$cache = new CacheProperties;
$cache->addProperty($ids);
$cache->addProperty('piggyAccounts');
$cache->addProperty('user-piggy-bank-accounts');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
@ -648,6 +656,7 @@ class AccountRepository implements AccountRepositoryInterface
/**
* @deprecated
*
* @param $accountId
*
* @return Account

View File

@ -13,6 +13,7 @@ use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Support\CacheProperties;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Log;
@ -44,7 +45,16 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function first()
{
return Auth::user()->transactionjournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
$cache = new CacheProperties;
$cache->addProperty('user-first-journal');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$entry = Auth::user()->transactionjournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
$cache->store($entry);
return $entry;
}
/**