class ApcuCacheFactory extends AbstractCacheFactory implements InMemoryCacheFactory (View source)

Factory to instantiate an ApcuAdapter for use in caching.

Note that APCu cache may not be shared between your webserver and the CLI. Flushing the cache from your terminal may not flush the cache used by the webserver. See https://github.com/symfony/symfony/discussions/54066

Properties

protected LoggerInterface|null $logger from  AbstractCacheFactory

Methods

public
__construct(LoggerInterface|null $logger = null)

No description

protected
CacheInterface
createCache(string $class, array $args, bool $useInjector = true)

Creates an object with a PSR-16 interface, usually from a PSR-6 class name.

protected
CacheInterface
prepareCacheForUse(CacheInterface $cacheAdapter, bool $useInjector)

Prepare a cache adapter for use.

protected
CacheInterface
instantiateCache(string $class, array $args, bool $useInjector)

Instantiates a cache adapter, either via the dependency injector or using the new keyword.

protected
bool
addLogger(CacheInterface $cache)

No description

public
object|null
create(string $service, array $params = [])

No description

public
CacheItemPoolInterface
createPsr6(string $service, array $params = [])

Create a PSR6-compliant cache adapter

Details

__construct(LoggerInterface|null $logger = null)

No description

Parameters

LoggerInterface|null $logger

Logger instance to assign

protected CacheInterface createCache(string $class, array $args, bool $useInjector = true)

Creates an object with a PSR-16 interface, usually from a PSR-6 class name.

Quick explanation of caching standards:

  • Symfony cache implements the PSR-6 standard
  • Symfony provides adapters which wrap a PSR-6 backend with a PSR-16 interface
  • Silverstripe uses the PSR-16 interface to interact with caches. It does not directly interact with the PSR-6 classes
  • Psr\SimpleCache\CacheInterface is the php interface of the PSR-16 standard. All concrete cache classes Silverstripe code interacts with should implement this interface

Further reading:

Parameters

string $class
array $args
bool $useInjector

Return Value

CacheInterface

protected CacheInterface prepareCacheForUse(CacheInterface $cacheAdapter, bool $useInjector)

Prepare a cache adapter for use.

This wraps a PSR6 adapter inside a PSR16 one. It also adds the loggers.

Parameters

CacheInterface $cacheAdapter
bool $useInjector

Return Value

CacheInterface

protected CacheInterface instantiateCache(string $class, array $args, bool $useInjector)

Instantiates a cache adapter, either via the dependency injector or using the new keyword.

Parameters

string $class
array $args
bool $useInjector

Return Value

CacheInterface

protected bool addLogger(CacheInterface $cache)

No description

Parameters

CacheInterface $cache

Return Value

bool

object|null create(string $service, array $params = [])

No description

Parameters

string $service

The class name of the service.

array $params

The constructor parameters.

Return Value

object|null

The created service instances.

CacheItemPoolInterface createPsr6(string $service, array $params = [])

Create a PSR6-compliant cache adapter

Parameters

string $service
array $params

Return Value

CacheItemPoolInterface