Documentation

CacheManager extends CacheLib

Cache

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Cloudrexx Development Team info@cloudrexx.com

version
1.0.1
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
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

$arrSettings  : mixed
$objTpl  : mixed
$strCachePath  : mixed
$arrPageContent  : array<string|int, mixed>
Page info (url, locale, ...)
$dynFuncs  : array<string|int, mixed>
Dynamic ESI variable callbacks
$dynVars  : array<string|int, mixed>
Dynamic ESI variable callbacks
$intCachingTime  : int
$jsonData  : JsonData
$opCacheEngine  : mixed
$opCacheEngines  : array<string|int, mixed>
Used op cache engines
$readOnlySetting  : array<string|int, mixed>
$ssiProxy  : ReverseProxyProxy
$objSettings  : mixed

Methods

__construct()  : mixed
PHP5 constructor
_deleteAllFiles()  : mixed
Delete all cached file's of the cache system
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
forceClearCache()  : mixed
Calls the related Clear Function from Lib and sets an OK-Message
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
parseEsiVars()  : string
Parses the dynamic ESI variables and functions in the given content
setCachedLocaleData()  : mixed
Sets the cached locale data
showSettings()  : mixed
Show settings of the module
updateSettings()  : mixed
Update settings and write them to the database
checkCacheDir()  : mixed
Makes sure that the cache directory exists and is writable
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
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.
parseMemcachedSettings()  : mixed
parseReverseProxySettings()  : mixed
Parses reverse proxy settings to current template
parseSsiProcessorSettings()  : mixed
Parses reverse ESI/SSI processor settings to current template
selectBestLanguageFromRequest()  : array<string|int, mixed>
Returns the necessary data to later identify the matching locale
setCachePath()  : mixed
Sets the cache path
parseOPCacheEngines()  : mixed
parseUserCacheEngines()  : mixed

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'

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

$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()

$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.

Methods

__construct()

PHP5 constructor

public __construct() : mixed
Tags
global

object $objTemplate

global

array $_ARRAYLANG

_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

forceClearCache()

Calls the related Clear Function from Lib and sets an OK-Message

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

array $_ARRAYLANG

global

object $objTemplate

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

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

showSettings()

Show settings of the module

public showSettings() : mixed
Tags
global

object $objTemplate

global

array $_ARRAYLANG

updateSettings()

Update settings and write them to the database

public updateSettings() : mixed
Tags
global

object $objDatabase

global

object $objTemplate

global

array $_ARRAYLANG

checkCacheDir()

Makes sure that the cache directory exists and is writable

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

The contrexx instance

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

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.

parseReverseProxySettings()

Parses reverse proxy settings to current template

protected parseReverseProxySettings() : mixed

parseSsiProcessorSettings()

Parses reverse ESI/SSI processor settings to current template

protected parseSsiProcessorSettings() : mixed

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