Skip to content

Commit

Permalink
Update Cache operation
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 27, 2020
1 parent a5388d2 commit afbcac3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
use loophp\collection\Transformation\Transform;
use loophp\collection\Transformation\Truthy;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

use function is_callable;
use function is_resource;
Expand Down Expand Up @@ -246,7 +247,7 @@ public function associate(

public function cache(?CacheItemPoolInterface $cache = null): CollectionInterface
{
return $this->run(new Cache($cache));
return $this->run(new Cache($cache ?? new ArrayAdapter()));
}

public function chunk(int ...$size): CollectionInterface
Expand Down
5 changes: 2 additions & 3 deletions src/Operation/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use loophp\collection\Contract\Operation;
use loophp\collection\Iterator\CacheIterator;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

/**
* @psalm-template TKey
Expand All @@ -19,9 +18,9 @@
*/
final class Cache extends AbstractOperation implements Operation
{
public function __construct(?CacheItemPoolInterface $cache = null)
public function __construct(CacheItemPoolInterface $cache)
{
$this->storage['cache'] = $cache ?? new ArrayAdapter();
$this->storage['cache'] = $cache;
}

public function __invoke(): Closure
Expand Down

0 comments on commit afbcac3

Please sign in to comment.