class MemoryCacheFactory

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Cache/MemoryCache/MemoryCacheFactory.php \Drupal\Core\Cache\MemoryCache\MemoryCacheFactory

Hierarchy

  • class \Drupal\Core\Cache\MemoryCache\MemoryCacheFactory implements \Drupal\Core\Cache\CacheFactoryInterface

Expanded class hierarchy of MemoryCacheFactory

1 string reference to 'MemoryCacheFactory'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses MemoryCacheFactory
cache.backend.memory.memory in core/core.services.yml
Drupal\Core\Cache\MemoryCache\MemoryCacheFactory

File

core/lib/Drupal/Core/Cache/MemoryCache/MemoryCacheFactory.php, line 8

Namespace

Drupal\Core\Cache\MemoryCache
View source
class MemoryCacheFactory implements CacheFactoryInterface {
    
    /**
     * Instantiated memory cache bins.
     *
     * @var \Drupal\Core\Cache\MemoryBackend[]
     */
    protected $bins = [];
    
    /**
     * Constructs a MemoryCounterBackendFactory object.
     *
     * @param \Drupal\Component\Datetime\TimeInterface|null $time
     *   The time service.
     */
    public function __construct(?TimeInterface $time = NULL) {
        if (!$time) {
            @trigger_error('Calling ' . __METHOD__ . '() without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3387233', E_USER_DEPRECATED);
            $this->time = \Drupal::service(TimeInterface::class);
        }
    }
    
    /**
     * {@inheritdoc}
     */
    public function get($bin) {
        if (!isset($this->bins[$bin])) {
            $this->bins[$bin] = new MemoryCache($this->time);
        }
        return $this->bins[$bin];
    }

}

Members

Title Sort descending Modifiers Object type Summary
MemoryCacheFactory::$bins protected property Instantiated memory cache bins.
MemoryCacheFactory::get public function
MemoryCacheFactory::__construct public function Constructs a MemoryCounterBackendFactory object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.