Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Smarty_CacheResource
  • Smarty_CacheResource_Custom
  • Smarty_CacheResource_KeyValueStore
  • Smarty_Internal_CacheResource_File
  • Overview
  • Package
  • Class
  • Todo
  • Download

Class Smarty_CacheResource_KeyValueStore

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.

Smarty_CacheResource
Extended by Smarty_CacheResource_KeyValueStore
Abstract
Package: Smarty\Cacher
Author: Rodney Rehm
Located at plugins/smarty/smarty_source/sysplugins/smarty_cacheresource_keyvaluestore.php
Methods summary
public
# populate( Smarty_Template_Cached $cached, Smarty_Internal_Template $_template )

populate Cached Object with meta data from Resource

populate Cached Object with meta data from Resource

Parameters

$cached
cached object
$_template
template object
public
# populateTimestamp( Smarty_Template_Cached $cached )

populate Cached Object with timestamp and exists from Resource

populate Cached Object with timestamp and exists from Resource

Parameters

$cached
cached object
public boolean
# process( Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null )

Read the cached template and process the header

Read the cached template and process the header

Parameters

$_template
template object
$cached
cached object

Returns

boolean
true or false if the cached content does not exist
public boolean
# writeCachedContent( Smarty_Internal_Template $_template, string $content )

Write the rendered template output to cache

Write the rendered template output to cache

Parameters

$_template
template object
$content
content to cache

Returns

boolean
success
public integer
# clearAll( Smarty $smarty, integer $exp_time = null )

Empty cache }

Empty cache }

Parameters

$smarty
Smarty object
$exp_time
expiration time [being ignored]

Returns

integer
number of cache files deleted [always -1]

Uses

Smarty_CacheResource_KeyValueStore::purge()
to clear the whole store
Smarty_CacheResource_KeyValueStore::invalidate()
to mark everything outdated if purge() is inapplicable
public integer
# clear( Smarty $smarty, string $resource_name, string $cache_id, string $compile_id, integer $exp_time )

Empty cache for a specific template }

Empty cache for a specific template }

Parameters

$smarty
Smarty object
$resource_name
template name
$cache_id
cache id
$compile_id
compile id
$exp_time
expiration time [being ignored]

Returns

integer
number of cache files deleted [always -1]

Uses

buildCachedFilepath() to generate the CacheID
Smarty_CacheResource_KeyValueStore::invalidate()
to mark CacheIDs parent chain as outdated
Smarty_CacheResource_KeyValueStore::delete()
to remove CacheID from cache
protected string
# getTemplateUid( Smarty $smarty, string $resource_name, string $cache_id, string $compile_id )

Get template's unique ID

Get template's unique ID

Parameters

$smarty
Smarty object
$resource_name
template name
$cache_id
cache id
$compile_id
compile id

Returns

string
filepath of cache file
protected string
# sanitize( string $string )

Sanitize CacheID components

Sanitize CacheID components

Parameters

$string
CacheID component to sanitize

Returns

string
sanitized CacheID component
protected boolean
# 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 )

Fetch and prepare a cache object.

Fetch and prepare a cache object.

Parameters

$cid
CacheID to fetch
$resource_name
template name
$cache_id
cache id
$compile_id
compile id
$content
cached content
$timestamp
$timestamp cached timestamp (epoch)
$resource_uid
resource's uid

Returns

boolean
success
protected
# addMetaTimestamp( string & $content )

Add current microtime to the beginning of $cache_content }

Add current microtime to the beginning of $cache_content }

Parameters

$content
$content the content to be cached
protected float
# getMetaTimestamp( string & $content )

Extract the timestamp the $content was cached

Extract the timestamp the $content was cached

Parameters

$content
$content the cached content

Returns

float
the 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 )

Invalidate CacheID

Invalidate CacheID

Parameters

$cid
CacheID
$resource_name
template name
$cache_id
cache id
$compile_id
compile id
$resource_uid
source's uid

Used by

Smarty_CacheResource_KeyValueStore::clearAll()
to mark everything outdated if purge() is inapplicable
Smarty_CacheResource_KeyValueStore::clear()
to mark CacheIDs parent chain as outdated
protected float
# getLatestInvalidationTimestamp( string $cid, string $resource_name = null, string $cache_id = null, string $compile_id = null, string $resource_uid = null )

Determine the latest timestamp known to the invalidation chain

Determine the latest timestamp known to the invalidation chain

Parameters

$cid
CacheID to determine latest invalidation timestamp of
$resource_name
template name
$cache_id
cache id
$compile_id
compile id
$resource_uid
source's filepath

Returns

float
the microtime the CacheID was invalidated
protected array
# listInvalidationKeys( string $cid, string $resource_name = null, string $cache_id = null, string $compile_id = null, string $resource_uid = null )

Translate a CacheID into the list of applicable InvalidationKeys. Splits "some|chain|into|an|array" into array( '#clearAll#', 'some', 'some|chain', 'some|chain|into', ... )

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

$cid
CacheID to translate
$resource_name
template name
$cache_id
cache id
$compile_id
compile id
$resource_uid
source's filepath

Returns

array
list of InvalidationKeys

Uses

$invalidationKeyPrefix to prepend to each InvalidationKey
public boolean
# hasLock( Smarty $smarty, Smarty_Template_Cached $cached )

Check is cache is locked for this template

Check is cache is locked for this template

Parameters

$smarty
Smarty object
$cached
cached object

Returns

boolean
true or false if cache is locked

Overrides

Smarty_CacheResource::hasLock()
public boolean|
# acquireLock( Smarty $smarty, Smarty_Template_Cached $cached )

Lock cache for this template

Lock cache for this template

Parameters

$smarty
Smarty object
$cached
cached object

Returns

boolean|

Overrides

Smarty_CacheResource::acquireLock()
public boolean|
# releaseLock( Smarty $smarty, Smarty_Template_Cached $cached )

Unlock cache for this template

Unlock cache for this template

Parameters

$smarty
Smarty object
$cached
cached object

Returns

boolean|

Overrides

Smarty_CacheResource::releaseLock()
abstract protected array
# read( array $keys )

Read values for a set of keys from cache

Read values for a set of keys from cache

Parameters

$keys
list of keys to fetch

Returns

array
list of values with the given keys used as indexes
abstract protected boolean
# write( array $keys, integer $expire = null )

Save values for a set of keys to cache

Save values for a set of keys to cache

Parameters

$keys
list of values to save
$expire
expiration time

Returns

boolean
true on success, false on failure
abstract protected boolean
# delete( array $keys )

Remove values from cache

Remove values from cache

Parameters

$keys
list of keys to delete

Returns

boolean
true on success, false on failure

Used by

Smarty_CacheResource_KeyValueStore::clear()
to remove CacheID from cache
protected boolean
# purge( )

Remove all values from cache

Remove all values from cache

Returns

boolean
true on success, false on failure

Used by

Smarty_CacheResource_KeyValueStore::clearAll()
to clear the whole store
Methods inherited from Smarty_CacheResource
getCachedContent(), invalidLoadedCache(), load(), locked()
Properties summary
protected array $contents

cache for contents

cache for contents

# array()
protected array $timestamps

cache for timestamps

cache for timestamps

# array()
Properties inherited from Smarty_CacheResource
$resources, $sysplugins
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen