Documentation

Cache extends CacheLib

Cache

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Cloudrexx Development Team info@cloudrexx.com

version
3.1.2
subpackage

coremodule_cache

Table of Contents

Constants

CACHE_DIRECTORY_OFFSET_ESI  = 'esi/'
ESI cache directory offset
CACHE_DIRECTORY_OFFSET_PAGE  = 'page/'
Page cache directory offset
CACHE_ENGINE_OFF  = 'off'
cache off
CACHE_ENGINE_ZEND_OPCACHE  = 'zendopcache'
zend opcache extension
HTTP_STATUS_CODE_HEADER  = 'X-StatusCode'
LOCALE_CACHE_FILE_NAME  = 'Locale.dat'
File name for page cache locale data
PARSE_ESI_ALL  = 3
Parse both ESI variables and functions
PARSE_ESI_FUNCTIONS  = 2
Parse ESI functions
PARSE_ESI_NONE  = 0
Parse neither ESI variables nor functions
PARSE_ESI_VARS  = 1
Parse ESI variables

Properties

$arrCacheablePages  : mixed
$boolIsEnabled  : mixed
$strCacheFilename  : mixed
$strCachePath  : mixed
$apiUrlString  : string
$arrPageContent  : array<string|int, mixed>
Page info (url, locale, ...)
$currentUrl  : mixed
$dynFuncs  : array<string|int, mixed>
Dynamic ESI variable callbacks
$dynVars  : array<string|int, mixed>
Dynamic ESI variable callbacks
$exceptions  : array<string|int, mixed>
$forceUserbased  : bool
$intCachingTime  : int
$jsonData  : JsonData
$opCacheEngine  : mixed
$opCacheEngines  : array<string|int, mixed>
Used op cache engines
$readOnlySetting  : array<string|int, mixed>
$requestedPageId  : mixed
$ssiProxy  : ReverseProxyProxy
$tempWidgetVarChannel  : mixed
$tempWidgetVarPageId  : mixed
$tempWidgetVarThemeId  : mixed

Methods

__construct()  : mixed
Constructor
_deleteAllFiles()  : mixed
Delete all cached file's of the cache system
addException()  : mixed
clearCache()  : mixed
Flush all cache instances
clearPublicCache()  : bool
Clears the complete public cache or just for a specific component.
clearReverseProxyCache()  : mixed
Drops a cache page on reverse proxy cache
clearSsiCache()  : mixed
Drops all cached ESI/SSI elements
clearSsiCachePage()  : mixed
Drops the ESI cache for a specific call
clearUserBasedEsiCache()  : mixed
Clear user based ESI cache
clearUserBasedPageCache()  : mixed
Clear user based page cache
deactivateNotUsedOpCaches()  : mixed
deleteComponentFiles()  : mixed
Delete all cached files for a component from cache-folder
deleteNonPagePageCache()  : mixed
Drops all page cache files that do not belong to a page Those are cached header redirects
deleteSingleFile()  : mixed
Delete all specific file from cache-folder
endContrexxCaching()  : mixed
End caching functions. Check for a sessionId: if not set, write pagecontent to a file.
forceClearCache()  : mixed
Calls the Clear Function for the given cache engine
forceUserbasedPageCache()  : mixed
Forces page cache to be stored per user
getAllOpCacheEngines()  : mixed
getCacheFileNameFromUrl()  : string
Gets the local cache file name for an URL
getCacheFileNameSearchPartsFromUrl()  : mixed
Returns the validated file search parts of the URL
getEsiContent()  : string
Returns the ESI/SSI content for a (json)data call
getOpCacheActive()  : mixed
getOpCacheEngine()  : mixed
getRandomizedEsiContent()  : string
Each entry of $esiContentInfos consists of an array like: array( <adapterName>, <adapterMethod>, <params>, )
getSettings()  : array<string|int, mixed>
Creates an array containing all important cache-settings
getSsiProxy()  : ReverseProxy
Returns the current SSI proxy
initEsiDynVars()  : mixed
Loads dynamic ESI variables and functions
internalEsiParsing()  : string
Parses ESI directives internally if configured to do so
isException()  : bool
This parses the list of exceptions (defined in endContrexxCaching()), which will not be cached. Each entry can be: - A component name, this will stop caching for the whole component - An array with the component name as key and a list of conditions as value. In that case, the sub-conditions can either be a cmd of the component or a callback (function($page) {}) which returns true if the exception matches and false otherwise.
parseEsiVars()  : string
Parses the dynamic ESI variables and functions in the given content
setCachedLocaleData()  : mixed
Sets the cached locale data
startContrexxCaching()  : void
Start caching functions. If this page is already cached, load it, otherwise create new file
writeCacheFileForRequest()  : mixed
Writes the cache file for the current request
checkCacheDir()  : mixed
Makes sure that the cache directory exists and is writable
cleanupCacheFiles()  : mixed
Removes all page cache files for a request
getActivatedCacheEngines()  : mixed
getApiResponseForUrl()  : string
Returns the content of the API response for an API URL This gets data internally and does not do a HTTP request!
getCachedLocaleData()  : array<string|int, mixed>
Returns the cached locale data
getDomainsAndPorts()  : array<string|int, mixed>
Returns all domains and ports this instance of cloudrexx can be reached at
getReverseProxyConfiguration()  : array<string|int, mixed>
Gets the configuration value for reverse proxy
getSsiProcessorConfiguration()  : array<string|int, mixed>
Gets the configuration value for external ESI/SSI processor
getUrlFromApi()  : Url
Wrapper for \Cx\Core\Routing\Url::fromApi() This ensures correct param order
initContrexxCaching()  : mixed
initOPCaching()  : mixed
initRequestInfo()  : mixed
Initializes basic request info (url, locale, ...)
isActive()  : mixed
isConfigured()  : mixed
isInstalled()  : mixed
isReadOnlySetting()  : bool
Checks if the given key is a read-only setting.
selectBestLanguageFromRequest()  : array<string|int, mixed>
Returns the necessary data to later identify the matching locale
setCachePath()  : mixed
Sets the cache path

Constants

CACHE_DIRECTORY_OFFSET_ESI

ESI cache directory offset

public mixed CACHE_DIRECTORY_OFFSET_ESI = 'esi/'

CACHE_DIRECTORY_OFFSET_PAGE

Page cache directory offset

public mixed CACHE_DIRECTORY_OFFSET_PAGE = 'page/'

CACHE_ENGINE_OFF

cache off

public mixed CACHE_ENGINE_OFF = 'off'

CACHE_ENGINE_ZEND_OPCACHE

zend opcache extension

public mixed CACHE_ENGINE_ZEND_OPCACHE = 'zendopcache'

HTTP_STATUS_CODE_HEADER

public mixed HTTP_STATUS_CODE_HEADER = 'X-StatusCode'

LOCALE_CACHE_FILE_NAME

File name for page cache locale data

public mixed LOCALE_CACHE_FILE_NAME = 'Locale.dat'

PARSE_ESI_ALL

Parse both ESI variables and functions

public mixed PARSE_ESI_ALL = 3

PARSE_ESI_FUNCTIONS

Parse ESI functions

public mixed PARSE_ESI_FUNCTIONS = 2

PARSE_ESI_NONE

Parse neither ESI variables nor functions

public mixed PARSE_ESI_NONE = 0

PARSE_ESI_VARS

Parse ESI variables

public mixed PARSE_ESI_VARS = 1

Properties

$arrCacheablePages

public mixed $arrCacheablePages = array()

$apiUrlString

protected string $apiUrlString = ''

This cannot be set to it's value until DB is initialized (since Url::from* needs DB)

$arrPageContent

Page info (url, locale, ...)

protected array<string|int, mixed> $arrPageContent = array()

$dynFuncs

Dynamic ESI variable callbacks

protected array<string|int, mixed> $dynFuncs = array()

$dynVars

Dynamic ESI variable callbacks

protected array<string|int, mixed> $dynVars = array()

$exceptions

protected array<string|int, mixed> $exceptions = array()

List of exceptions which will not be cached For format see isException()

$forceUserbased

protected bool $forceUserbased = false

Whether to store page cache user based or not

$intCachingTime

protected int $intCachingTime

Cache lease time in seconds

$opCacheEngines

Used op cache engines

protected array<string|int, mixed> $opCacheEngines = array()

Cache engine names, empty for none

$readOnlySetting

protected array<string|int, mixed> $readOnlySetting = []

List of setting options that have been set through an environment variable and are therefore read only.

$requestedPageId

protected mixed $requestedPageId = 0

$tempWidgetVarChannel

protected mixed $tempWidgetVarChannel = ''

$tempWidgetVarPageId

protected mixed $tempWidgetVarPageId = ''

$tempWidgetVarThemeId

protected mixed $tempWidgetVarThemeId = ''

Methods

__construct()

Constructor

public __construct() : mixed
Tags
global

array $_CONFIG

_deleteAllFiles()

Delete all cached file's of the cache system

public _deleteAllFiles([mixed $cacheEngine = null ]) : mixed
Parameters
$cacheEngine : mixed = null

clearCache()

Flush all cache instances

public clearCache([string $cacheEngine = null ][, bool $includingEsi = true ]) : mixed
Parameters
$cacheEngine : string = null

See CACHE_ENGINE_* constants

$includingEsi : bool = true

(optional) Whether to drop ESI cache

Tags
see
PageEventListener

on update of page objects

clearPublicCache()

Clears the complete public cache or just for a specific component.

public clearPublicCache([SystemComponentController|null $component = null ]) : bool
Parameters
$component : SystemComponentController|null = null

The component whose public cache should be cleared. If null, all public caches will be cleared.

Return values
bool

Returns true if the cache was successfully cleared, false otherwise.

clearReverseProxyCache()

Drops a cache page on reverse proxy cache

public clearReverseProxyCache(mixed $urlPattern) : mixed
Parameters
$urlPattern : mixed

clearSsiCache()

Drops all cached ESI/SSI elements

public clearSsiCache([mixed $urlPattern = '' ]) : mixed
Parameters
$urlPattern : mixed = ''

clearSsiCachePage()

Drops the ESI cache for a specific call

public clearSsiCachePage(string $adapterName, string $adapterMethod[, array<string|int, mixed> $params = array() ]) : mixed
Parameters
$adapterName : string

(Json)Data adapter name

$adapterMethod : string

(Json)Data method name

$params : array<string|int, mixed> = array()

(optional) params for (Json)Data method call

Tags
todo

Only drop this specific content instead of complete cache

clearUserBasedEsiCache()

Clear user based ESI cache

public clearUserBasedEsiCache([string $sessionId = '' ]) : mixed

If argument $sessionId is set, then only the cache of the user (identified by sessionid $sessionId) will be flushed. Otherwise (if $sessionId is not set), the complete user based cache is flushed.

Parameters
$sessionId : string = ''

The session ID of the user of whom to clear the esi cache from. If not set, then all used based cach is flusehd.

clearUserBasedPageCache()

Clear user based page cache

public clearUserBasedPageCache([string $sessionId = '' ]) : mixed

If argument $sessionId is set, then only the cache of the user (identified by sessionid $sessionId) will be flushed. Otherwise (if $sessionId is not set), the complete user based cache is flushed.

Parameters
$sessionId : string = ''

The session ID of the user of whom to clear the page cache from. If not set, then all used based cach is flusehd.

deactivateNotUsedOpCaches()

public deactivateNotUsedOpCaches() : mixed

deleteComponentFiles()

Delete all cached files for a component from cache-folder

public deleteComponentFiles(mixed $componentName) : mixed
Parameters
$componentName : mixed

deleteNonPagePageCache()

Drops all page cache files that do not belong to a page Those are cached header redirects

public deleteNonPagePageCache() : mixed

deleteSingleFile()

Delete all specific file from cache-folder

public deleteSingleFile(mixed $intPageId) : mixed
Parameters
$intPageId : mixed

endContrexxCaching()

End caching functions. Check for a sessionId: if not set, write pagecontent to a file.

public endContrexxCaching(mixed $page, mixed $endcode) : mixed
Parameters
$page : mixed
$endcode : mixed

forceClearCache()

Calls the Clear Function for the given cache engine

public forceClearCache([string $cacheEngine = null ]) : mixed
Parameters
$cacheEngine : string = null

forceUserbasedPageCache()

Forces page cache to be stored per user

public forceUserbasedPageCache() : mixed

getCacheFileNameFromUrl()

Gets the local cache file name for an URL

public getCacheFileNameFromUrl(string $url, string $originalUrl[, bool $withCacheInfoPart = true ]) : string
Parameters
$url : string

URL to get file name for

$originalUrl : string

URL of the page that ESI is parsed for

$withCacheInfoPart : bool = true

(optional) Adds info part (default true)

Return values
string

File name (without path)

getCacheFileNameSearchPartsFromUrl()

Returns the validated file search parts of the URL

public getCacheFileNameSearchPartsFromUrl(string $url, string $originalUrl) : mixed
Parameters
$url : string

URL to parse

$originalUrl : string

URL of the page that ESI is parsed for

Tags
@return

array <fileNamePrefix>=><parsedValue> type array

getEsiContent()

Returns the ESI/SSI content for a (json)data call

public getEsiContent(string $adapterName, string $adapterMethod[, array<string|int, mixed> $params = array() ]) : string
Parameters
$adapterName : string

(Json)Data adapter name

$adapterMethod : string

(Json)Data method name

$params : array<string|int, mixed> = array()

(optional) params for (Json)Data method call

Return values
string

ESI/SSI directives to put into HTML code

getRandomizedEsiContent()

Each entry of $esiContentInfos consists of an array like: array( <adapterName>, <adapterMethod>, <params>, )

public getRandomizedEsiContent(array<string|int, mixed> $esiContentInfos[, int $count = 1 ]) : string
Parameters
$esiContentInfos : array<string|int, mixed>

List of ESI content info arrays

$count : int = 1

(optional) Number of unique random entries to parse

Return values
string

ESI randomized include code

getSettings()

Creates an array containing all important cache-settings

public getSettings() : array<string|int, mixed>
Tags
global

object $objDatabase

Return values
array<string|int, mixed>

$arrSettings

initEsiDynVars()

Loads dynamic ESI variables and functions

public initEsiDynVars() : mixed

internalEsiParsing()

Parses ESI directives internally if configured to do so

public internalEsiParsing(string $htmlCode[, mixed $cxNotYetInitialized = false ]) : string
Parameters
$htmlCode : string

HTML code to replace ESI directives in

$cxNotYetInitialized : mixed = false
Return values
string

Parsed HTML code

isException()

This parses the list of exceptions (defined in endContrexxCaching()), which will not be cached. Each entry can be: - A component name, this will stop caching for the whole component - An array with the component name as key and a list of conditions as value. In that case, the sub-conditions can either be a cmd of the component or a callback (function($page) {}) which returns true if the exception matches and false otherwise.

public isException(mixed $page, Page $cx) : bool
  • A callback (function($cx, $page) }) which returns true if the exception matches and false otherwise.
Parameters
$page : mixed
$cx : Page

Current page

Return values
bool

True if current request matches an exception, false otherwise

parseEsiVars()

Parses the dynamic ESI variables and functions in the given content

public parseEsiVars(string $content[, int $flags = self::PARSE_ESI_ALL ]) : string
Parameters
$content : string

Content to parse

$flags : int = self::PARSE_ESI_ALL

Controls the parsing behavior. Can be one or a combination of static::PARSE_ESI_*

Return values
string

Parsed content

setCachedLocaleData()

Sets the cached locale data

public setCachedLocaleData(Cx $cx) : mixed

Default locale and the following hashtables are cached: <localeCode> to <localeId> <localeCountryCode> to <localeCodes>

Parameters
$cx : Cx

Cx instance

startContrexxCaching()

Start caching functions. If this page is already cached, load it, otherwise create new file

public startContrexxCaching(mixed $cx) : void
Parameters
$cx : mixed

writeCacheFileForRequest()

Writes the cache file for the current request

public writeCacheFileForRequest(Page $page, array<string|int, mixed> $headers, string $endcode[, mixed $forceUserbased = false ]) : mixed
Parameters
$page : Page

Current page (might be null for redirects before postResolve)

$headers : array<string|int, mixed>

List of headers set for the current response

$endcode : string

Current response

$forceUserbased : mixed = false

checkCacheDir()

Makes sure that the cache directory exists and is writable

protected checkCacheDir(Cx $cx) : mixed
Parameters
$cx : Cx

The contrexx instance

cleanupCacheFiles()

Removes all page cache files for a request

protected cleanupCacheFiles(string $filename, int $pageId, bool $userbased) : mixed
Parameters
$filename : string

Request hash (as in $this->strCacheFilename)

$pageId : int

Page ID

$userbased : bool

True if the current request is userbased, false otherwise

getActivatedCacheEngines()

protected getActivatedCacheEngines() : mixed

getApiResponseForUrl()

Returns the content of the API response for an API URL This gets data internally and does not do a HTTP request!

protected getApiResponseForUrl(string $url[, Response|null &$responseObj = null ]) : string
Parameters
$url : string

API URL

$responseObj : Response|null = null

(optional) Response object

Tags
throws
Exception

If JsonAdapter request did not succeed

Return values
string

API content or empty string

getCachedLocaleData()

Returns the cached locale data

protected getCachedLocaleData() : array<string|int, mixed>

Default locale and the following hashtables are cached: <localeCode> to <localeId> <localeCountryCode> to <localeCodes>

Return values
array<string|int, mixed>

Cached locale data or empty array

getDomainsAndPorts()

Returns all domains and ports this instance of cloudrexx can be reached at

protected getDomainsAndPorts() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of domains and ports (array(array(0=>{domain}, 1=>{port})))

getReverseProxyConfiguration()

Gets the configuration value for reverse proxy

protected getReverseProxyConfiguration() : array<string|int, mixed>
Return values
array<string|int, mixed>

'ip' and 'port' of reverse proxy

getSsiProcessorConfiguration()

Gets the configuration value for external ESI/SSI processor

protected getSsiProcessorConfiguration() : array<string|int, mixed>
Return values
array<string|int, mixed>

'ip' and 'port' of external ESI/SSI processor

getUrlFromApi()

Wrapper for \Cx\Core\Routing\Url::fromApi() This ensures correct param order

protected getUrlFromApi(string $adapterName, string $adapterMethod, array<string|int, mixed> $params) : Url
Parameters
$adapterName : string

(Json)Data adapter name

$adapterMethod : string

(Json)Data method name

$params : array<string|int, mixed>

(optional) params for (Json)Data method call

Return values
Url

URL for (Json)Data call

initContrexxCaching()

protected initContrexxCaching() : mixed

initRequestInfo()

Initializes basic request info (url, locale, ...)

protected initRequestInfo() : mixed

isActive()

protected isActive(mixed $cacheEngine) : mixed
Parameters
$cacheEngine : mixed

isConfigured()

protected isConfigured(mixed $cacheEngine[, mixed $user = false ]) : mixed
Parameters
$cacheEngine : mixed
$user : mixed = false

isInstalled()

protected isInstalled(mixed $cacheEngine) : mixed
Parameters
$cacheEngine : mixed

isReadOnlySetting()

Checks if the given key is a read-only setting.

protected isReadOnlySetting(string $key) : bool
Parameters
$key : string

The setting key to check.

Return values
bool

True if the key is read-only, false otherwise.

selectBestLanguageFromRequest()

Returns the necessary data to later identify the matching locale

protected selectBestLanguageFromRequest(Cx $cx) : array<string|int, mixed>

This method does not use database or cached database data

Parameters
$cx : Cx

Cx instance

Return values
array<string|int, mixed>

Locale info

setCachePath()

Sets the cache path

protected setCachePath() : mixed

        
On this page

Search results