abstract | |
---|---|
extends |
Smarty_CacheResource |
Smarty Cache Handler Base for Key/Value Storage Implementations This class implements the functionality required to use simple key/value stores for hierarchical cache groups. key/value stores like memcache or APC do not support wildcards in keys, therefore a cache group cannot be cleared like "a|*" - which is no problem to filesystem and RDBMS implementations. This implementation is based on the concept of invalidation. While one specific cache can be identified and cleared, any range of caches cannot be identified. For this reason each level of the cache group hierarchy can have its own value in the store. These values are nothing but microtimes, telling us when a particular cache group was cleared for the last time. These keys are evaluated for every cache read to determine if the cache has been invalidated since it was created and should hence be treated as inexistent. Although deep hierarchies are possible, they are not recommended. Try to keep your cache groups as shallow as possible. Anything up 3-5 parents should be ok. So »a|b|c« is a good depth where »a|b|c|d|e|f|g|h|i|j|k« isn't. Try to join correlating cache groups: if your cache groups look somewhat like »a|b|$page|$items|$whatever« consider using »a|b|c|$page-$items-$whatever« instead.
Methods | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
public
|
populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template): void
populate Cached Object with meta data from Resource
populate Cached Object with meta data from Resource Parameters
Implements |
# | ||||||||||||||
public
|
populateTimestamp(Smarty_Template_Cached $cached): void
populate Cached Object with timestamp and exists from Resource
populate Cached Object with timestamp and exists from Resource Parameters
Implements |
# | ||||||||||||||
public
|
process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null, boolean $update = false): boolean
Read the cached template and process the header
Read the cached template and process the header Parameters
Returnstrue or false if the cached content does not exist Implements |
# | ||||||||||||||
public
|
writeCachedContent(Smarty_Internal_Template $_template, string $content): boolean
Write the rendered template output to cache
Write the rendered template output to cache Parameters
Returnssuccess Implements |
# | ||||||||||||||
public
|
readCachedContent(Smarty_Internal_Template $_template): string|false
Read cached template from cache
Read cached template from cache Parameters
Returnscontent Implements |
# | ||||||||||||||
public
|
clearAll(Smarty $smarty, integer $exp_time = null): integer
Empty cache
{@internal the $exp_time argument is ignored altogether }}
Empty cache {@internal the $exp_time argument is ignored altogether }} Parameters
Returnsnumber of cache files deleted [always -1] Implements |
# | ||||||||||||||
public
|
clear(Smarty $smarty, string $resource_name, string $cache_id, string $compile_id, integer $exp_time): int
Empty cache for a specific template
{@internal the $exp_time argument is ignored altogether}}
Empty cache for a specific template {@internal the $exp_time argument is ignored altogether}} Parameters
Returnsnumber of cache files deleted [always -1] Throws
Implements |
# | ||||||||||||||
protected
|
getTemplateUid(Smarty $smarty, string $resource_name): string
Get template's unique ID
Get template's unique ID Parameters
Returnsfilepath of cache file Throws
|
# | ||||||||||||||
protected
|
sanitize(string $string): string
Sanitize CacheID components
Sanitize CacheID components Parameters
Returnssanitized CacheID component |
# | ||||||||||||||
protected
|
fetch(
string $cid,
string $resource_name = null,
string $cache_id = null,
string $compile_id = null,
string &$content = null,
integer &$timestamp = null,
string $resource_uid = null,
): boolean
Fetch and prepare a cache object.
Fetch and prepare a cache object. Parameters
Returnssuccess |
# | ||||||||||||||
protected
|
addMetaTimestamp(string &$content)
Add current microtime to the beginning of $cache_content
{@internal the header uses 8 Bytes, the first 4 Bytes are the…
Add current microtime to the beginning of $cache_content {@internal the header uses 8 Bytes, the first 4 Bytes are the seconds, the second 4 Bytes are the microseconds}} Parameters
|
# | ||||||||||||||
protected
|
getMetaTimestamp(string &$content): float
Extract the timestamp the $content was cached
Extract the timestamp the $content was cached Parameters
Returnsthe microtime the content was cached |
# | ||||||||||||||
protected
|
invalidate(
string $cid = null,
string $resource_name = null,
string $cache_id = null,
string $compile_id = null,
string $resource_uid = null,
): void
Invalidate CacheID
Invalidate CacheID Parameters
|
# | ||||||||||||||
protected
|
getLatestInvalidationTimestamp(
string $cid,
string $resource_name = null,
string $cache_id = null,
string $compile_id = null,
string $resource_uid = null,
): float
Determine the latest timestamp known to the invalidation chain
Determine the latest timestamp known to the invalidation chain Parameters
Returnsthe microtime the CacheID was invalidated |
# | ||||||||||||||
protected
|
listInvalidationKeys(
string $cid,
string $resource_name = null,
string $cache_id = null,
string $compile_id = null,
string $resource_uid = null,
): array
Translate a CacheID into the list of applicable InvalidationKeys.
Splits 'some|chain|into|an|array' into array( '…
Translate a CacheID into the list of applicable InvalidationKeys. Splits 'some|chain|into|an|array' into array( '#clearAll#', 'some', 'some|chain', 'some|chain|into', ... ) Parameters
Returnslist of InvalidationKeys |
# | ||||||||||||||
public
|
hasLock(Smarty $smarty, Smarty_Template_Cached $cached): boolean
Check is cache is locked for this template
Check is cache is locked for this template Parameters
Returnstrue or false if cache is locked Overrides |
# | ||||||||||||||
public
|
acquireLock(Smarty $smarty, Smarty_Template_Cached $cached): bool|void
Lock cache for this template
Lock cache for this template Parameters
Overrides |
# | ||||||||||||||
public
|
releaseLock(Smarty $smarty, Smarty_Template_Cached $cached): bool|void
Unlock cache for this template
Unlock cache for this template Parameters
Overrides |
# | ||||||||||||||
abstract
protected
|
read(array $keys): array
Read values for a set of keys from cache
Read values for a set of keys from cache Parameters
Returnslist of values with the given keys used as indexes Implemented by |
# | ||||||||||||||
abstract
protected
|
write(array $keys, int $expire = null): boolean
Save values for a set of keys to cache
Save values for a set of keys to cache Parameters
Returnstrue on success, false on failure Implemented by |
# | ||||||||||||||
abstract
protected
|
delete(array $keys): boolean
Remove values from cache
Remove values from cache Parameters
Returnstrue on success, false on failure Implemented by |
# | ||||||||||||||
protected
|
purge(): boolean
Remove *all* values from cache
Remove all values from cache Returnstrue on success, false on failure Overriden by |
# |
Methods inherited from Smarty_CacheResource |
---|
getCachedContent(), locked(), load() |
Properties | |||
---|---|---|---|
protected
|
array
|
$contents = []
|
# |
protected
|
array
|
$timestamps = []
|
# |
Properties inherited from Smarty_CacheResource |
---|
$sysplugins |