diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 1c272c76ab..92d9d09c3e 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -17,7 +17,6 @@ use Symfony\Component\Cache\CacheInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ArrayTrait; -use Symfony\Component\Cache\Traits\GetTrait; /** * @author Nicolas Grekas
@@ -25,7 +24,6 @@ use Symfony\Component\Cache\Traits\GetTrait;
class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface
{
use ArrayTrait;
- use GetTrait;
private $createCacheItem;
@@ -51,6 +49,21 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
);
}
+ /**
+ * {@inheritdoc}
+ */
+ public function get(string $key, callable $callback, float $beta = null)
+ {
+ $item = $this->getItem($key);
+
+ // ArrayAdapter works in memory, we don't care about stampede protection
+ if (INF === $beta || !$item->isHit()) {
+ $this->save($item->set($callback($item)));
+ }
+
+ return $item->get();
+ }
+
/**
* {@inheritdoc}
*/
diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php
index 44929f9e76..d4e7598f33 100644
--- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php
+++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php
@@ -14,15 +14,12 @@ namespace Symfony\Component\Cache\Adapter;
use Psr\Cache\CacheItemInterface;
use Symfony\Component\Cache\CacheInterface;
use Symfony\Component\Cache\CacheItem;
-use Symfony\Component\Cache\Traits\GetTrait;
/**
* @author Titouan Galopin