CSCacheUtils
in package
Tags
Table of Contents
- CLEAR_DB_OBJECT = 'CS_CLEAR_DB_OBJECT'
- TYPE_FAST_DB = 'MEMORY'
- Constant for a performance cache of database results, which must be fast, but may also drop unimportant data before expiration (e.g. completely in the Memory)
- TYPE_FAST_LOCAL = 'SHARED_MEMORY'
- Constant for a performance cache of local results, which must be fast, but may also drop unimportant data before expiration (e.g. completely in the Memory)
- TYPE_LARGE = 'PERSISTENT'
- Constant for a cache containing large amount of data, which will never be dropped before expiration and may be shared on several instances
- TYPE_LARGE_LOCAL = 'PERSISTENT_LOCAL'
- Constant for a cache containing large amount of data, which will never be dropped before expiration and may not be shared on several instances
- TYPE_PERSISTENT = 'PRIO'
- Constant for a cache containing high priority data, which should never be dropped and must be the same shared value on several instances
- add() : void
- Adds something to the cache using a key and class It is recommended to use CSCacheUtils::setObjectPersistent, CSCacheUtils::setSnippetHtml or CSCacheUtils::setSnippet
- addCMSObject() : void
- Adds any object to the cache in a CMS context It is recommended to use CSCacheUtils::setHtmlSnippet or CSCacheUtils::setSnippet
- addObject() : void
- Adds any object to the global CONTENTSERV cache It is recommended to use CSCacheUtils::setObjectPersistent or CSCacheUtils::setSnippet
- clearLocalSnippetCache() : void
- Clears all snippets with the matching tags from the Cache
- clearObjectDBCache() : void
- Marks all or the given Database Tables as modified invaliditing all Objects which have been added before using the CSCacheUtils::setObjectDB or CSCacheUtils::setObjectDBShared methods
- clearSnippetCache() : void
- Clears all snippets with the matching tags from the Cache
- freeMemory() : void
- Frees the memory used by the internal request cache
- get() : string
- Retrieves something from the cache using the right key and class It is recommended to use CSCacheUtils::getObjectPersistent, CSCacheUtils::getSnippetHtml or CSCacheUtils::getSnippet
- getCMSObject() : mixed
- Retrieves any object from the cache in a CMS context It is recommended to use CSCacheUtils::getHtmlSnippet or CSCacheUtils::getSnippet
- getFromMd5() : any
- Loads anything which had been stored using the storeToMd5 method
- getLocalCache() : mixed
- Gets any Object from the fastest available local cache.
- getLocalSharedCacheFolder() : string
- Returns the folder where local cache files should be placed within.
- getLocalSharedFolder() : string
- Returns the folder where locale shared files should be placed within.
- getLocalSnippet() : bool|mixed
- Gets an unserialized Snippet from the Cache.
- getObject() : mixed
- Retrieves any object from the global CONTENTSERV cache It is recommended to use CSCacheUtils::getObjectPersistent or CSCacheUtils::getSnippet
- getObjectDB() : bool|mixed
- Gets any Object from the current requests cache, which has already been queried before.
- getObjectDBShared() : bool|mixed
- Gets any Object from the current requests cache, which has already been queried before (in this or other requests) and is marked as shared.
- getObjectPersistent() : bool|mixed
- Gets an Object from the Cache.
- getSeparatedKey() : string
- Creates a unique key for a key with the given separators.
- getSharedCacheFolder() : string
- Returns the folder where cache files should be placed within.
- getSharedDownloadFolder() : string
- Returns the folder where local cache download files should be placed within.
- getSharedFolder() : string
- Returns the folder where shared files should be placed within.
- getSharedLogsFolder() : string
- Returns the folder where log files should be placed within.
- getSharedMamCacheFolder() : string
- Returns the folder where mam cache files will be placed within.
- getSharedTranslationFolder() : string
- Returns the folder where all translation files should be placed within.
- getSharedUploadFolder() : string
- Returns the folder where all uploaded files should be placed within.
- getSnippet() : bool|mixed
- Gets an unserialized Snippet from the Cache.
- getSnippetHtml() : bool|string
- Gets a HTML (String) Snippet from the Cache (e.g. in the CMS).
- hasMemcache() : mixed
- lock() : mixed
- setLocalCache() : mixed
- Adds any Object to the fastest available local cache.
- setLocalSnippet() : void
- Adds any object to the Cache which will be serialized. Those Snippets may be large and are stored in the filesystem.
- setObjectDB() : void
- Adds any Object to the current requests cache. It is only available in this request or until the given $dbTables are changed.
- setObjectDBShared() : void
- Adds any Object to the current Database cache. It is available until the given $dbTables are changed.
- setObjectPersistent() : void
- Adds any Object to the Cache which will be serialized.
- setSnippet() : string
- Adds any object to the Cache which will be serialized. Those Snippets may be large and are stored in the filesystem.
- setSnippetHtml() : string
- Adds a HTML (String) Snippet to the Cache (e.g. in the CMS). Those Snippets may be large and are stored in the filesystem.
- storeToMd5() : string
- Converts any data to a MD5 which is temporarly stored into a cache and can be accessed by the current session
- unlock() : mixed
Constants
CLEAR_DB_OBJECT
public
mixed
CLEAR_DB_OBJECT
= 'CS_CLEAR_DB_OBJECT'
Tags
TYPE_FAST_DB
Constant for a performance cache of database results, which must be fast, but may also drop unimportant data before expiration (e.g. completely in the Memory)
public
mixed
TYPE_FAST_DB
= 'MEMORY'
Tags
TYPE_FAST_LOCAL
Constant for a performance cache of local results, which must be fast, but may also drop unimportant data before expiration (e.g. completely in the Memory)
public
mixed
TYPE_FAST_LOCAL
= 'SHARED_MEMORY'
Tags
TYPE_LARGE
Constant for a cache containing large amount of data, which will never be dropped before expiration and may be shared on several instances
public
mixed
TYPE_LARGE
= 'PERSISTENT'
Tags
TYPE_LARGE_LOCAL
Constant for a cache containing large amount of data, which will never be dropped before expiration and may not be shared on several instances
public
mixed
TYPE_LARGE_LOCAL
= 'PERSISTENT_LOCAL'
Tags
TYPE_PERSISTENT
Constant for a cache containing high priority data, which should never be dropped and must be the same shared value on several instances
public
mixed
TYPE_PERSISTENT
= 'PRIO'
Tags
Methods
add()
Adds something to the cache using a key and class It is recommended to use CSCacheUtils::setObjectPersistent, CSCacheUtils::setSnippetHtml or CSCacheUtils::setSnippet
public
static add(string $key, string $type, string $content) : void
The key is the name that must be used later to get the content back. The type is a kind of class and can be chosen arbitrary and is used to define a subfolder in the data/cache/[class] directory, where the cached content should be stored to.
Parameters
- $key : string
-
the key of the content that must be used to get the content back later
- $type : string
-
the class of the content - e.g. xml or xls or story
- $content : string
-
the content to be stored
Tags
Return values
void —addCMSObject()
Adds any object to the cache in a CMS context It is recommended to use CSCacheUtils::setHtmlSnippet or CSCacheUtils::setSnippet
public
static addCMSObject(string $key, mixed $content[, string $cacheSeperateFor = "Story|AccessLevel|Subproject|Language" ]) : void
Parameters
- $key : string
-
the key that was used before to push the content to the cache
- $content : mixed
-
any object which should be added to the cache
- $cacheSeperateFor : string = "Story|AccessLevel|Subproject|Language"
-
the cache criterias for which the cache should be identical (for more details see in this class description)
Tags
Return values
void —addObject()
Adds any object to the global CONTENTSERV cache It is recommended to use CSCacheUtils::setObjectPersistent or CSCacheUtils::setSnippet
public
static addObject(string $key, mixed $content[, string $subfolder = '' ]) : void
Parameters
- $key : string
-
the key that was used before to push the content to the cache
- $content : mixed
-
any object which should be added to the cache
- $subfolder : string = ''
-
the subfolder the cache is located
Tags
Return values
void —clearLocalSnippetCache()
Clears all snippets with the matching tags from the Cache
public
static clearLocalSnippetCache([array<string|int, mixed> $aTags = array() ]) : void
Parameters
- $aTags : array<string|int, mixed> = array()
-
Cache tags which have been defined in the setSnippet methods
Tags
Return values
void —clearObjectDBCache()
Marks all or the given Database Tables as modified invaliditing all Objects which have been added before using the CSCacheUtils::setObjectDB or CSCacheUtils::setObjectDBShared methods
public
static clearObjectDBCache([array<string|int, mixed> $mDBTables = true ][, bool $bPersistent = true ]) : void
Parameters
- $mDBTables : array<string|int, mixed> = true
- $bPersistent : bool = true
Tags
Return values
void —clearSnippetCache()
Clears all snippets with the matching tags from the Cache
public
static clearSnippetCache([array<string|int, mixed> $aTags = array() ]) : void
Parameters
- $aTags : array<string|int, mixed> = array()
-
Cache tags which have been defined in the setSnippet methods
Tags
Return values
void —freeMemory()
Frees the memory used by the internal request cache
public
static freeMemory() : void
Tags
Return values
void —get()
Retrieves something from the cache using the right key and class It is recommended to use CSCacheUtils::getObjectPersistent, CSCacheUtils::getSnippetHtml or CSCacheUtils::getSnippet
public
static get(string $key, string $type[, int $cacheMinutes = 10 ]) : string
The key and type must be the same as used before when the content was pushed to the cache.
Parameters
- $key : string
-
the key that was used before to push the content to the cache
- $type : string
-
the class of the content that was used before to push the content to the cache - e.g. xml or xls or story
- $cacheMinutes : int = 10
-
an expiration timeout for the cached content - during this time the content is regarded as valid
Tags
Return values
string —the content that was pushed to the cache before for the given key and type if available and not expired / false otherwise
getCMSObject()
Retrieves any object from the cache in a CMS context It is recommended to use CSCacheUtils::getHtmlSnippet or CSCacheUtils::getSnippet
public
static getCMSObject(string $key[, string $cacheMinutes = '120' ][, string $cacheSeperateFor = "Story|AccessLevel|Subproject|Language" ]) : mixed
Parameters
- $key : string
-
the key that was used before to push the content to the cache
- $cacheMinutes : string = '120'
-
an expiration timeout for the cached content - during this time the content is regarded as valid
- $cacheSeperateFor : string = "Story|AccessLevel|Subproject|Language"
-
the cache criterias for which the cache should be identical (for more details see in this class description)
Tags
Return values
mixed —any object which had been added to the cache before
getFromMd5()
Loads anything which had been stored using the storeToMd5 method
public
static getFromMd5(string $md5) : any
Parameters
- $md5 : string
-
the stored md5 hash
Tags
Return values
any —the stored data
getLocalCache()
Gets any Object from the fastest available local cache.
public
static getLocalCache(string $sKey[, mixed $bUseMemoryDatabase = true ]) : mixed
Normally a shared memory is used. Therefor the cache is not persistent
Parameters
- $sKey : string
-
the unique ID of the cache data
- $bUseMemoryDatabase : mixed = true
Tags
Return values
mixed —$value value which has been stored
getLocalSharedCacheFolder()
Returns the folder where local cache files should be placed within.
public
static getLocalSharedCacheFolder() : string
This folder is available from only the current server using loadbalancing
Tags
Return values
string —the path to the cache folder in the filesystem
getLocalSharedFolder()
Returns the folder where locale shared files should be placed within.
public
static getLocalSharedFolder() : string
This folder is available from only the current server using loadbalancing
Tags
Return values
string —the path to the shared folder in the filesystem
getLocalSnippet()
Gets an unserialized Snippet from the Cache.
public
static getLocalSnippet(string $sKey) : bool|mixed
Parameters
- $sKey : string
-
the unique ID of the Snippet to search
Tags
Return values
bool|mixed —an added snippet for the key as any object or false, if no snippet has been found
getObject()
Retrieves any object from the global CONTENTSERV cache It is recommended to use CSCacheUtils::getObjectPersistent or CSCacheUtils::getSnippet
public
static getObject(string $key[, string $cacheMinutes = '0' ][, string $subfolder = '' ]) : mixed
Parameters
- $key : string
-
the key that was used before to push the content to the cache
- $cacheMinutes : string = '0'
-
an expiration timeout for the cached content - during this time the content is regarded as valid
- $subfolder : string = ''
-
the subfolder the cache is located
Tags
Return values
mixed —any object which had been added to the cache before
getObjectDB()
Gets any Object from the current requests cache, which has already been queried before.
public
static getObjectDB(string $sKey) : bool|mixed
Parameters
- $sKey : string
-
the unique ID of the Database result
Tags
Return values
bool|mixed —the Database result for the key as any object or false, if no result has been found
getObjectDBShared()
Gets any Object from the current requests cache, which has already been queried before (in this or other requests) and is marked as shared.
public
static getObjectDBShared(string $sKey[, array<string|int, mixed> $aDatabaseTables = array() ]) : bool|mixed
Parameters
- $sKey : string
-
the unique ID of the Database result
- $aDatabaseTables : array<string|int, mixed> = array()
-
the Database tables which have been queried for the result, to be invalidated, if those tables change.
Tags
Return values
bool|mixed —the Database result for the key as any object or false, if no result has been found
getObjectPersistent()
Gets an Object from the Cache.
public
static getObjectPersistent(string $sKey[, array<string|int, mixed> $aFiles = array() ]) : bool|mixed
Parameters
- $sKey : string
-
the unique ID of the Object
- $aFiles : array<string|int, mixed> = array()
-
the path to optional files (like config files). If they have been touched the cached Object is invalid.
Tags
Return values
bool|mixed —an added Object for the key as or false, if no Object has been found
getSeparatedKey()
Creates a unique key for a key with the given separators.
public
static getSeparatedKey(string $sKey[, string $sCacheSeparatorKey = 'Story|AccessLevel|Subproject|Language' ]) : string
Parameters
- $sKey : string
-
the key that was used before to push the content to the cache
- $sCacheSeparatorKey : string = 'Story|AccessLevel|Subproject|Language'
-
the cache criteria for which the cache should be identical (for more details see in this class description)
Tags
Return values
string —a unique key for the given key and the current cache criteria
getSharedCacheFolder()
Returns the folder where cache files should be placed within.
public
static getSharedCacheFolder() : string
This folder is available from all servers using loadbalancing
Tags
Return values
string —the path to the cache folder in the filesystem
getSharedDownloadFolder()
Returns the folder where local cache download files should be placed within.
public
static getSharedDownloadFolder() : string
This folder is available from only the current server using loadbalancing
Tags
Return values
string —the path to the cache download folder in the filesystem
getSharedFolder()
Returns the folder where shared files should be placed within.
public
static getSharedFolder() : string
This folder is available from all servers using loadbalancing
Tags
Return values
string —the path to the shared folder in the filesystem
getSharedLogsFolder()
Returns the folder where log files should be placed within.
public
static getSharedLogsFolder() : string
This folder is available from all servers using loadbalancing or only for the current server (corresponding to the current settings)
Tags
Return values
string —the path to the logs folder in the filesystem
getSharedMamCacheFolder()
Returns the folder where mam cache files will be placed within.
public
static getSharedMamCacheFolder() : string
This folder is available from all servers using loadbalancing
Tags
Return values
string —the path to the mam cache folder in the filesystem
getSharedTranslationFolder()
Returns the folder where all translation files should be placed within.
public
static getSharedTranslationFolder() : string
This folder is available from all servers using loadbalancing or only for the current server (corresponding to the current settings)
Tags
Return values
string —with the folder where all translation files should be placed within.
getSharedUploadFolder()
Returns the folder where all uploaded files should be placed within.
public
static getSharedUploadFolder() : string
This folder is available from all servers using loadbalancing or only for the current server (corresponding to the current settings)
Tags
Return values
string —getSnippet()
Gets an unserialized Snippet from the Cache.
public
static getSnippet(string $sKey) : bool|mixed
Parameters
- $sKey : string
-
the unique ID of the Snippet to search
Tags
Return values
bool|mixed —an added snippet for the key as any object or false, if no snippet has been found
getSnippetHtml()
Gets a HTML (String) Snippet from the Cache (e.g. in the CMS).
public
static getSnippetHtml(string $sKey) : bool|string
Parameters
- $sKey : string
-
the unique ID of the Snippet to search
Tags
Return values
bool|string —an added snippet for the key as string or false, if no snippet has been found
hasMemcache()
public
static hasMemcache() : mixed
Tags
Return values
mixed —lock()
public
static lock(mixed $key[, mixed $maxWaitingSec = 60 ][, mixed $parallelThreadCount = 1 ][, mixed $expiration = 72000 ]) : mixed
Parameters
- $key : mixed
- $maxWaitingSec : mixed = 60
- $parallelThreadCount : mixed = 1
- $expiration : mixed = 72000
Tags
Return values
mixed —setLocalCache()
Adds any Object to the fastest available local cache.
public
static setLocalCache(string $sKey, mixed $mValue[, mixed $bUseMemoryDatabase = true ]) : mixed
Normally a shared memory is used. Therefor the cache is not persistent
Parameters
- $sKey : string
-
the unique ID of the cache data
- $mValue : mixed
-
value to store
- $bUseMemoryDatabase : mixed = true
Tags
Return values
mixed —$value value to store
setLocalSnippet()
Adds any object to the Cache which will be serialized. Those Snippets may be large and are stored in the filesystem.
public
static setLocalSnippet(string $sKey, mixed $mValue[, array<string|int, mixed> $aTags = array() ][, int $iCacheTime = 7200 ]) : void
If you want to store high performance required data, you can use CSCacheUtils::setObjectPersistent instead.
Parameters
- $sKey : string
-
the unique ID of the Snippet
- $mValue : mixed
-
the Snippet representation
- $aTags : array<string|int, mixed> = array()
-
Cache tags which can be used to identify the element when calling CSCacheUtils::clearSnippetCache()
- $iCacheTime : int = 7200
-
the time the snippet is cached in seconds
Tags
Return values
void —setObjectDB()
Adds any Object to the current requests cache. It is only available in this request or until the given $dbTables are changed.
public
static setObjectDB(string $sKey, mixed $mValue[, array<string|int, mixed> $aDatabaseTables = array() ]) : void
Normally it will be used to cache the results of Database queries which may be called multiple times in the request. If the result should be cached for multiple requests, use CSCacheUtils::setObjectDBShared instead.
Parameters
- $sKey : string
-
the unique ID of the Database result
- $mValue : mixed
-
the Database result
- $aDatabaseTables : array<string|int, mixed> = array()
-
the Database tables which have been queried for the result, to be invalidated, if those tables change.
Tags
Return values
void —setObjectDBShared()
Adds any Object to the current Database cache. It is available until the given $dbTables are changed.
public
static setObjectDBShared(string $sKey, mixed $mValue[, array<string|int, mixed> $aDatabaseTables = array() ]) : void
Normally it will be used to cache long-running results of Database queries which may be called multiple times in different requests. If the result should not be cached for multiple requests, use CSCacheUtils::setObjectDB instead.
Parameters
- $sKey : string
-
the unique ID of the Database result
- $mValue : mixed
-
the Database result
- $aDatabaseTables : array<string|int, mixed> = array()
-
the Database tables which have been queried for the result, to be invalidated, if those tables change.
Tags
Return values
void —setObjectPersistent()
Adds any Object to the Cache which will be serialized.
public
static setObjectPersistent(string $sKey, mixed $mValue[, array<string|int, mixed> $aFiles = array() ][, int $iCacheTime = 7200 ]) : void
Those data is high performant (e.g. in RAM) but also stored another time in a persistent medium (Database). It may also be used to read and cache data from files (like config files) If you just want to store less frequent required or big data, you should better use CSCacheUtils::setSnippet instead.
Parameters
- $sKey : string
-
the unique ID of the Object
- $mValue : mixed
-
the Object to add
- $aFiles : array<string|int, mixed> = array()
-
the path to optional files (like config files). If they are touched the cache is resetted.
- $iCacheTime : int = 7200
-
the time the Object is cached in seconds
Tags
Return values
void —setSnippet()
Adds any object to the Cache which will be serialized. Those Snippets may be large and are stored in the filesystem.
public
static setSnippet(string $sKey, mixed $mValue[, array<string|int, mixed> $aTags = array() ][, int $iCacheTime = 7200 ]) : string
If you want to store high performance required data, you can use CSCacheUtils::setObjectPersistent instead.
Parameters
- $sKey : string
-
the unique ID of the Snippet
- $mValue : mixed
-
the Snippet representation
- $aTags : array<string|int, mixed> = array()
-
Cache tags which can be used to identify the element when calling CSCacheUtils::clearSnippetCache()
- $iCacheTime : int = 7200
-
the time the snippet is cached in seconds
Tags
Return values
string —The cached value
setSnippetHtml()
Adds a HTML (String) Snippet to the Cache (e.g. in the CMS). Those Snippets may be large and are stored in the filesystem.
public
static setSnippetHtml(string $sKey, string $mValue[, array<string|int, mixed> $aTags = array() ][, int $iCacheTime = 7200 ]) : string
Parameters
- $sKey : string
-
the unique ID of the Snippet
- $mValue : string
-
the Snippet representation
- $aTags : array<string|int, mixed> = array()
-
Cache tags which can be used to identify the element when calling CSCacheUtils::clearSnippetCache()
- $iCacheTime : int = 7200
-
the time the snippet is cached in seconds
Tags
Return values
string —The cached value
storeToMd5()
Converts any data to a MD5 which is temporarly stored into a cache and can be accessed by the current session
public
static storeToMd5(mixed $data[, string $prefix = '' ]) : string
Parameters
- $data : mixed
-
the object which should be stored
- $prefix : string = ''
-
an optional prefix which should be added before the md5 hash
Tags
Return values
string —the md5 hash with the given prefix which may be used in the getFromMd5 method
unlock()
public
static unlock(mixed $key) : mixed
Parameters
- $key : mixed
