model/modx/modcachemanager.class.php
- package
- modx
- Classes
- modCacheManager
Description
Contains the xPDOCacheManager implementation for MODX.
\modCacheManager
- Extends from
- \xPDOCacheManager
- package
- modx
- Properties
- $modx
- Methods
- __construct
- autoPublish
- clearCache
- generateActionMap
- generateConfig
- generateContext
- generateLexiconTopic
- generateResource
- generateScript
- refresh
Description
The default xPDOCacheManager instance for MODX.
Through this class, MODX provides several types of default, file-based caching to reduce load and dependencies on the database, including:
- partial modResource caching, which stores the object properties, along with individual modElement cache items
- full caching of modContext and modSystemSetting data
- object-level caching
- db query-level caching
- optional JSON object caching for increased Ajax performance possibilities
Properties
Methods
__construct
__construct(
$xpdo, $options
=
array
)
:
Arguments
- $xpdo
- $options
Details
- visibility
- public
- final
- false
- static
- false
autoPublish
autoPublish(
array $options
=
array
)
:
array
Check for and process Resources with pub_date or unpub_date set to now or in past.
Arguments
- $options
- array
An array of options for the process.
Output
- array
- An array containing published and unpublished Resource counts.
Details
- visibility
- public
- final
- false
- static
- false
- todo
- Implement Context-isolated auto-publishing.
clearCache
clearCache(
array $paths
=
array, array $options
=
array
)
:
Clear part or all of the MODX cache.
Arguments
- $paths
- array
An optional array of paths, relative to the cache path, to be deleted. - $options
- array
An optional associative array of cache clearing options: <ul> <li><strong>objects</strong>: an array of objects or paths to flush from the db object cache</li> <li><strong>extensions</strong>: an array of file extensions to match when deleting the cache directories</li> </ul>
Details
- visibility
- public
- final
- false
- static
- false
- deprecated
- Use refresh()
generateActionMap
generateActionMap(
string $cacheKey, $options
=
array
)
:
array
Generates a cache file for the manager actions.
Arguments
- $cacheKey
- string
The key to use when caching the action map. - $options
Output
- array
- An array representing the action map.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
generateConfig
generateConfig(
array $options
=
array
)
:
array
Generates the system settings cache for a MODX site.
Arguments
- $options
- array
Options for system settings generation.
Output
- array
- The generated system settings array.
Details
- visibility
- public
- final
- false
- static
- false
generateContext
generateContext(
$key, array $options
=
array
)
:
array
Generates a cache entry for a MODX site Context.
Context cache entries can override site configuration settings and are responsible for loading the various listings and maps in the modX class, including resourceMap, aliasMap, and eventMap. It can also be used to setup or transform any other modX properties.
Arguments
- $key
- $options
- array
Options for system settings generation.
Output
- array
- An array containing all the context variable values.
Details
- visibility
- public
- final
- false
- static
- false
- todo
- Further refactor the generation of aliasMap and resourceMap so it uses less memory/file size.
generateLexiconTopic
generateLexiconTopic(
string $cacheKey, array $entries
=
array, array $options
=
array
)
:
array
Generates a lexicon topic cache file from a collection of entries
Arguments
- $cacheKey
- string
The key to use when caching the lexicon topic. - $entries
- array
An array of key => value pairs of lexicon entries. - $options
- array
An optional array of caching options.
Output
- array
- An array representing the lexicon topic cache.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
generateResource
generateResource(
\modResource $obj, array $options
=
array
)
:
array
Generates a cache entry for a Resource or Resource-derived object.
Resource classes can define their own cacheKey.
Arguments
- $obj
- \modResource
The Resource instance to be cached. - $options
- array
Options for resource generation.
Output
- array
- The generated resource representation.
Details
- visibility
- public
- final
- false
- static
- false
generateScript
generateScript(
\modScript $objElement, string $objContent
=
null, array $options
=
array
)
:
boolean|string
Generates a file representing an executable modScript function.
Arguments
- $objElement
- \modScript
A {@link modScript} instance to generate the script file for. - $objContent
- string
Optional script content to override the persistent instance. - $options
- array
An array of additional options for the operation.
Output
- boolean|string
- The actual generated source content representing the modScript or false if the source content could not be generated.
Details
- visibility
- public
- final
- false
- static
- false
refresh
refresh(
array $providers
=
array, array $results
=
array
)
:
array
Implements MODX cache refresh process, converting cache partitions to cache providers.
The default behavior is to call clean() with the provided options
Arguments
- $providers
- array
An associative array with keys representing the cache provider key and the value an array of options. - $results
- array
&$results An associative array for collecting results for each provider.
Output
- array
- An array of results for each provider that is refreshed.
Details
- visibility
- public
- final
- false
- static
- false