PhpArrayAdapter

class PhpArrayAdapter implements AdapterInterface

Caches items at warm up time using a PHP array that is stored in shared memory by OPCache since PHP 7.0.

Warmed up items are read-only and run-time discovered items are cached using a fallback adapter.

Traits

PhpArrayTrait

Methods

warmUp(array $values)

Store an array of cached values.

from PhpArrayTrait
clear()

{@inheritdoc}

from PhpArrayTrait
__construct(string $file, AdapterInterface $fallbackPool)
static CacheItemPoolInterface create(string $file, CacheItemPoolInterface $fallbackPool)

This adapter should only be used on PHP 7.0+ to take advantage of how PHP stores arrays in its latest versions. This factory method decorates the given fallback pool with this adapter only if the current PHP version is supported.

CacheItem getItem($key)

{@inheritdoc}

getItems(array $keys = array())

{@inheritdoc}

hasItem($key)

{@inheritdoc}

deleteItem($key)

{@inheritdoc}

deleteItems(array $keys)

{@inheritdoc}

save(CacheItemInterface $item)

{@inheritdoc}

saveDeferred(CacheItemInterface $item)

{@inheritdoc}

commit()

{@inheritdoc}

static throwOnRequiredClass($class)

Details

warmUp(array $values)

Store an array of cached values.

Parameters

array $values The cached values

clear()

{@inheritdoc}

__construct(string $file, AdapterInterface $fallbackPool)

Parameters

string $file The PHP file were values are cached
AdapterInterface $fallbackPool A pool to fallback on when an item is not hit

static CacheItemPoolInterface create(string $file, CacheItemPoolInterface $fallbackPool)

This adapter should only be used on PHP 7.0+ to take advantage of how PHP stores arrays in its latest versions. This factory method decorates the given fallback pool with this adapter only if the current PHP version is supported.

Parameters

string $file The PHP file were values are cached
CacheItemPoolInterface $fallbackPool Fallback for old PHP versions or opcache disabled

Return Value

CacheItemPoolInterface

CacheItem getItem($key)

{@inheritdoc}

Parameters

$key

Return Value

CacheItem

getItems(array $keys = array())

{@inheritdoc}

return \Traversable|CacheItem[]

Parameters

array $keys

hasItem($key)

{@inheritdoc}

Parameters

$key

deleteItem($key)

{@inheritdoc}

Parameters

$key

deleteItems(array $keys)

{@inheritdoc}

Parameters

array $keys

save(CacheItemInterface $item)

{@inheritdoc}

Parameters

CacheItemInterface $item

saveDeferred(CacheItemInterface $item)

{@inheritdoc}

Parameters

CacheItemInterface $item

commit()

{@inheritdoc}

static throwOnRequiredClass($class)

Parameters

$class

Exceptions

ReflectionException When $class is not found and is required

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.3/Symfony/Component/Cache/Adapter/PhpArrayAdapter.html