class CacheManager (View source)

The Cache Manager

Properties

protected CacheFactoryInterface $cacheFactory
protected ConfigurationManager $configurationManager
protected LoggerInterface $logger
protected Environment $environment
protected FrontendInterface[] $caches
protected CacheInterface[] $simpleCaches
protected CacheItemPoolInterface[] $cacheItemPools
protected array $persistentCaches
protected array $cacheConfigurations

Methods

void
injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

void
injectCacheFactory(CacheFactoryInterface $cacheFactory)

No description

void
injectConfigurationManager(ConfigurationManager $configurationManager)

No description

void
injectEnvironment(Environment $environment)

No description

void
setCacheConfigurations(array $cacheConfigurations)

Sets configurations for caches. The key of each entry specifies the cache identifier and the value is an array of configuration options.

void
registerCache(FrontendInterface $cache, bool $persistent = false)

Registers a cache so it can be retrieved at a later point.

getCache(string $identifier)

Returns the cache specified by $identifier

CacheInterface
getSimpleCache(string $identifier)

Return a SimpleCache frontend for the cache specified by $identifier

CacheItemPoolInterface
getCacheItemPool(string $identifier)

Return a SimpleCache frontend for the cache specified by $identifier

bool
hasCache(string $identifier)

Checks if the specified cache has been registered.

bool
isCachePersistent(string $identifier)

Checks if the specified cache is marked as "persistent".

void
flushCaches(bool $flushPersistentCaches = false)

Flushes all registered caches

void
flushCachesByTag(string $tag, bool $flushPersistentCaches = false)

Flushes entries tagged by the specified tag of all registered caches.

array
getCacheConfigurations()

Returns an array of cache configurations, indexed by cache identifier

void
flushSystemCachesByChangedFiles(string $fileMonitorIdentifier, array $changedFiles)

Flushes entries tagged with class names if their class source files have changed.

void
flushClassCachesByChangedFiles(array $changedFiles)

Flushes entries tagged with class names if their class source files have changed.

void
flushConfigurationCachesByChangedFiles(array $changedFiles)

Flushes caches as needed if settings, routes or policies have changed

void
flushTranslationCachesByChangedFiles(array $changedFiles)

Flushes I18n caches if translation files have changed

void
createAllCaches()

Instantiates all registered caches.

void
createCache(string $identifier)

Instantiates the cache for $identifier.

Details

void injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

Parameters

LoggerInterface $logger

Return Value

void

void injectCacheFactory(CacheFactoryInterface $cacheFactory)

No description

Parameters

CacheFactoryInterface $cacheFactory

Return Value

void

void injectConfigurationManager(ConfigurationManager $configurationManager)

No description

Parameters

ConfigurationManager $configurationManager

Return Value

void

void injectEnvironment(Environment $environment)

No description

Parameters

Environment $environment

Return Value

void

void setCacheConfigurations(array $cacheConfigurations)

Sets configurations for caches. The key of each entry specifies the cache identifier and the value is an array of configuration options.

Possible options are:

frontend backend backendOptions persistent

If one of the options is not specified, the default value is assumed. Existing cache configurations are preserved.

Parameters

array $cacheConfigurations

The cache configurations to set

Return Value

void

Exceptions

InvalidArgumentException

void registerCache(FrontendInterface $cache, bool $persistent = false)

Registers a cache so it can be retrieved at a later point.

Parameters

FrontendInterface $cache

The cache frontend to be registered

bool $persistent

Return Value

void

Exceptions

DuplicateIdentifierException

FrontendInterface getCache(string $identifier)

Returns the cache specified by $identifier

Parameters

string $identifier

Identifies which cache to return

Return Value

FrontendInterface

The specified cache frontend

Exceptions

NoSuchCacheException

CacheInterface getSimpleCache(string $identifier)

Return a SimpleCache frontend for the cache specified by $identifier

Parameters

string $identifier

Return Value

CacheInterface

CacheItemPoolInterface getCacheItemPool(string $identifier)

Return a SimpleCache frontend for the cache specified by $identifier

Parameters

string $identifier

Return Value

CacheItemPoolInterface

bool hasCache(string $identifier)

Checks if the specified cache has been registered.

Parameters

string $identifier

The identifier of the cache

Return Value

bool

true if a cache with the given identifier exists, otherwise false

bool isCachePersistent(string $identifier)

Checks if the specified cache is marked as "persistent".

Parameters

string $identifier

The identifier of the cache

Return Value

bool

true if the specified cache is persistent, false if it is not, or if the cache does not exist

void flushCaches(bool $flushPersistentCaches = false)

Flushes all registered caches

Parameters

bool $flushPersistentCaches

If set to true, even those caches which are flagged as "persistent" will be flushed

Return Value

void

void flushCachesByTag(string $tag, bool $flushPersistentCaches = false)

Flushes entries tagged by the specified tag of all registered caches.

Parameters

string $tag

Tag to search for

bool $flushPersistentCaches

If set to true, even those caches which are flagged as "persistent" will be flushed

Return Value

void

array getCacheConfigurations()

Returns an array of cache configurations, indexed by cache identifier

Return Value

array

void flushSystemCachesByChangedFiles(string $fileMonitorIdentifier, array $changedFiles)

Flushes entries tagged with class names if their class source files have changed.

Also flushes AOP proxy caches if a policy was modified.

This method is used as a slot for a signal sent by the system file monitor defined in the bootstrap scripts.

Note: Policy configuration handling is implemented here as well as other parts of Flow (like the security framework) are not fully initialized at the time needed.

Parameters

string $fileMonitorIdentifier

Identifier of the File Monitor

array $changedFiles

A list of full paths to changed files

Return Value

void

protected void flushClassCachesByChangedFiles(array $changedFiles)

Flushes entries tagged with class names if their class source files have changed.

Parameters

array $changedFiles

A list of full paths to changed files

Return Value

void

See also

flushSystemCachesByChangedFiles()

protected void flushConfigurationCachesByChangedFiles(array $changedFiles)

Flushes caches as needed if settings, routes or policies have changed

Parameters

array $changedFiles

A list of full paths to changed files

Return Value

void

See also

flushSystemCachesByChangedFiles()

protected void flushTranslationCachesByChangedFiles(array $changedFiles)

Flushes I18n caches if translation files have changed

Parameters

array $changedFiles

A list of full paths to changed files

Return Value

void

See also

flushSystemCachesByChangedFiles()

protected void createAllCaches()

Instantiates all registered caches.

Return Value

void

protected void createCache(string $identifier)

Instantiates the cache for $identifier.

Parameters

string $identifier

Return Value

void