Skip to content

Commit

Permalink
Remove singleton cache - fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fomvasss committed Jul 30, 2020
1 parent 0eb6777 commit 2510c3c
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/VariableManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,15 @@ public function set(string $key, $value = null)
*/
public function all(): array
{
if ($this->variables === null) {

$all = $this->cacheRepository->remember($this->config['cache']['name'], $this->config['cache']['time'], function () {
return $this->getCollection();
});

if ($all) {
$allByLocale = $this->locale ? $all->where('locale', $this->locale) : $all;
$this->variables = $allByLocale->pluck('value', 'key')->toArray();
} else {
$this->variables = [];
}

$all = $this->cacheRepository->remember($this->config['cache']['name'], $this->config['cache']['time'], function () {
return $this->getCollection();
});

if ($all) {
$allByLocale = $this->locale ? $all->where('locale', $this->locale) : $all;
$this->variables = $allByLocale->pluck('value', 'key')->toArray();
} else {
$this->variables = [];
}

return $this->variables;
Expand Down

0 comments on commit 2510c3c

Please sign in to comment.