Overview

Packages

  • akismet
  • None
  • PHP
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • plugins
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Signatures
    • Signed
    • Transport
  • wa-apps
    • blog
      • actions
        • backend
        • blog
        • comment
        • cron
        • design
        • frontend
        • page
        • plugin
        • post
      • api
        • v1
      • cli
      • layout
      • model
      • plugin
        • aksimet
        • category
        • emailsubscription
        • favorite
        • gravatar
        • import
        • markdown
        • myposts
        • tag
        • troll
      • settings
    • checklists
      • backend
      • json
    • contacts
      • backend
    • developer
    • dummy
    • guestbook
    • guestbook2
    • photos
      • album
      • api
        • v1
      • backend
      • design
      • dialog
      • frontend
      • page
      • photo
      • plugin
        • comment
        • imageeffects
        • import
        • publicgallery
        • watermark
      • search
      • settings
      • stack
      • tag
      • upload
    • site
      • backend
      • blocks
      • config
      • design
      • domains
      • files
      • frontend
      • helper
      • layout
      • pages
      • routing
      • setting
    • stickies
      • api
        • v1
      • sheet
      • stiky
  • wa-plugin
    • payment
    • shipping
    • sms
  • wa-plugins
    • shipping
      • usps
  • wa-system
    • API
    • Auth
      • Adapters
    • Autoload
    • Cache
      • Adapter
    • Captcha
    • Config
    • Contact
    • controller
    • currency
    • database
    • datetime
    • design
    • event
    • exception
    • files
    • image
    • layout
    • locale
    • log
    • mail
    • page
      • action
      • model
    • payment
    • plugin
    • request
    • response
    • routing
    • shipping
    • sms
    • storage
    • user
    • util
    • validator
    • view
    • webasyst
      • api
      • backend
      • cli
      • config
      • layout
      • login
      • model
      • password
      • payment
      • profile
      • settings
      • shipment
    • widget
    • workflow
  • waPlugins
    • Payment
  • webasyst
    • wa-system
      • helper

Classes

  • Smarty_CacheResource
  • Smarty_CacheResource_Custom
  • Smarty_CacheResource_KeyValueStore
  • Smarty_Internal_CacheResource_File
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

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 wa-system/vendors/smarty3/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
Smarty_Template_Cached
$cached cached object
$_template
Smarty_Internal_Template
$_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
Smarty_Template_Cached
$cached cached object
public booelan
# 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
Smarty_Internal_Template
$_template template object
$cached
Smarty_Template_Cached
$cached cached object

Returns

booelan
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
Smarty_Internal_Template
$_template template object
$content
string
$content content to cache

Returns

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

Empty cache

Empty cache

the $exp_time argument is ignored altogether }

Parameters

$smarty
Smarty
$smarty Smarty object
$exp_time
integer
$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

the $exp_time argument is ignored altogether}

Parameters

$smarty
Smarty
$smarty Smarty object
$resource_name
string
$resource_name template name
$cache_id
string
$cache_id cache id
$compile_id
string
$compile_id compile id
$exp_time
integer
$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
$smarty Smarty object
$resource_name
string
$resource_name template name
$cache_id
string
$cache_id cache id
$compile_id
string
$compile_id compile id

Returns

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

Sanitize CacheID components

Sanitize CacheID components

Parameters

$string
string
$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
string
$cid CacheID to fetch
$resource_name
string
$resource_name template name
$cache_id
string
$cache_id cache id
$compile_id
string
$compile_id compile id
$content
string
$content cached content
$timestamp
integer
&$timestamp cached timestamp (epoch)
$resource_uid
string
$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

the header uses 8 Bytes, the first 4 Bytes are the seconds, the second 4 Bytes are the microseconds}

Parameters

$content
string
&$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
string
&$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
string
$cid CacheID
$resource_name
string
$resource_name template name
$cache_id
string
$cache_id cache id
$compile_id
string
$compile_id compile id
$resource_uid
string
$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
string
$cid CacheID to determine latest invalidation timestamp of
$resource_name
string
$resource_name template name
$cache_id
string
$cache_id cache id
$compile_id
string
$compile_id compile id
$resource_uid
string
$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.

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
string
$cid CacheID to translate
$resource_name
string
$resource_name template name
$cache_id
string
$cache_id cache id
$compile_id
string
$compile_id compile id
$resource_uid
string
$resource_uid source's filepath

Returns

array
list of InvalidationKeys

Uses

$invalidationKeyPrefix to prepend to each InvalidationKey
public booelan
# 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
$smarty Smarty object
$cached
Smarty_Template_Cached
$cached cached object

Returns

booelan
true or false if cache is locked

Overrides

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

Lock cache for this template

Lock cache for this template

Parameters

$smarty
Smarty
$smarty Smarty object
$cached
Smarty_Template_Cached
$cached cached object

Overrides

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

Unlock cache for this template

Unlock cache for this template

Parameters

$smarty
Smarty
$smarty Smarty object
$cached
Smarty_Template_Cached
$cached cached object

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
array
$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
array
$keys list of values to save
$expire
integer
$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
array
$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 array()
#

cache for contents

cache for contents

protected array $timestamps array()
#

cache for timestamps

cache for timestamps

Properties inherited from Smarty_CacheResource
$resources, $sysplugins
My fork of Webasyst Framework API documentation generated by ApiGen 2.8.0