class DefaultCacheFactory extends AbstractCacheFactory (View source)

Creates the following cache adapters:

  • PhpFilesAdapter (falls back to FilesystemAdapter if PhpFilesAdapter isn't supported)
  • An optional in-memory cache such as Redis, Memcached, or APCu.

Properties

protected LoggerInterface|null $logger from  AbstractCacheFactory
protected array $args

Methods

public
__construct(array $args = [], 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 $args = [])

No description

protected
bool
isPHPFilesSupported()

Determine if PHP files is supported

Details

__construct(array $args = [], LoggerInterface|null $logger = null)

No description

Parameters

array $args

List of global options to merge with args during create()

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 $args = [])

No description

Parameters

string $service

The class name of the service.

array $args

Return Value

object|null

The created service instances.

protected bool isPHPFilesSupported()

Determine if PHP files is supported

Return Value

bool