mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Optimize queries for statistics.
This commit is contained in:
@@ -27,7 +27,6 @@ use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use JsonException;
|
||||
|
||||
use function Safe\json_encode;
|
||||
|
||||
/**
|
||||
@@ -78,20 +77,6 @@ class CacheProperties
|
||||
return Cache::has($this->hash);
|
||||
}
|
||||
|
||||
private function hash(): void
|
||||
{
|
||||
$content = '';
|
||||
foreach ($this->properties as $property) {
|
||||
try {
|
||||
$content = sprintf('%s%s', $content, json_encode($property, JSON_THROW_ON_ERROR));
|
||||
} catch (JsonException) {
|
||||
// @ignoreException
|
||||
$content = sprintf('%s%s', $content, hash('sha256', (string) Carbon::now()->getTimestamp()));
|
||||
}
|
||||
}
|
||||
$this->hash = substr(hash('sha256', $content), 0, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
*/
|
||||
@@ -99,4 +84,18 @@ class CacheProperties
|
||||
{
|
||||
Cache::forever($this->hash, $data);
|
||||
}
|
||||
|
||||
private function hash(): void
|
||||
{
|
||||
$content = '';
|
||||
foreach ($this->properties as $property) {
|
||||
try {
|
||||
$content = sprintf('%s%s', $content, json_encode($property, JSON_THROW_ON_ERROR));
|
||||
} catch (JsonException) {
|
||||
// @ignoreException
|
||||
$content = sprintf('%s%s', $content, hash('sha256', (string)Carbon::now()->getTimestamp()));
|
||||
}
|
||||
}
|
||||
$this->hash = substr(hash('sha256', $content), 0, 16);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user