class vB_Cache_XCache extends vB_Cache

XCache.

Handler that caches and retrieves data from XCache.

Traits

Constants

CACHE_STD

CACHE_FAST

CACHE_LARGE

CACHE_LOG_WRITE

CACHE_LOG_READSUCCESS

CACHE_LOG_READFAIL

CACHE_LOG_HASVALUE

CACHE_LOG_NOVALUE

CACHE_LOG_CLEAR

LOCK_PREFIX

Properties

static protected vB_Cache_XCache $instance A reference to the singleton instance
protected $values_read from vB_Cache
protected $no_values from vB_Cache
protected $metadata_life from vB_Cache
protected $metadata_update_min from vB_Cache
protected $meta_info from vB_Cache
protected $keys_used from vB_Cache
protected $noCache from vB_Cache
static protected $disableCache from vB_Cache
protected string $prefix Unique prefix for item's title, required for multiple forums on the same server using the same classes that read/write to memory from vB_Cache
protected string $cachetype Cache type of current object. from vB_Cache
protected $timeNow The current time - this is used a lot so let's make it a member variable. from vB_Cache
protected $meta_loaded from vB_Cache
static protected $cacheLogging from vB_Cache
static protected $actions from vB_Cache
protected $events

Methods

__sleep()

No description

__wakeup()

No description

__construct($cachetype)

Constructor protected to enforce singleton use.

static 
getDefaults()

Get the cache defaults.

from vB_Cache
static vB_Cache
instance($type = NULL)

Returns singleton instance of self.

static 
resetCache($expiredOnly = false)

No description

from vB_Cache
static 
resetAllCache($expiredOnly = false)

No description

from vB_Cache
string
write($key, $data, $lifetime_mins = false, $events = false)

Writes data as a cache object.

from vB_Cache
writeCache(array $cache)

Writes the cache data to storage.

saveCacheInfo($cacheid)

Based on the assumption that if we go back to a page we're likely to request a lot of the information we requested last time we were on that page, let's store the cached information.

from vB_Cache
restoreCacheInfo($cacheid)

If we used saveCacheInfo to save data, this will get it back.

from vB_Cache
bool
isLoaded(string $key)

has a value been loaded for this key?

from vB_Cache
mixed
readSingle($key, $write_lock = false, $save_meta = false)

Reads a cache object and returns the data.

from vB_Cache
array
readCache(string $key)

Reads the cache object from storage.

purge($cacheid)

Purges a cache object.

from vB_Cache
purgeCache(int $key)

Removes a cache object from storage.

expire(int/array $cache_ids)

Expires a cache object.

from vB_Cache
bool
expireCache($keys)

Sets a cache entry as expired in storage.

event(string $events)

Expires cache objects based on a triggered event.

static 
allCacheEvent($events)

No description

from vB_Cache
bool
lock(string $key)

Locks a cache entry.

unlock($key)

Unlocks a cache entry.

clean(bool $only_expired = true)

Cleans cache.

shutdown()

No description

cleanNow()

Tells the cache to trigger all events.

from vB_Cache
array
read(string $keys, bool $writeLock = false, bool $save_meta = false)

Reads an array of cache objects from storage.

from vB_Cache
updateTime($time = false)

This updates the time. It is useful only for testing. Otherwise it does nothing

from vB_Cache
static 
logCacheAction($cacheid, $action, $type = 4, $size = 0)

If cache logging is enabled this stores the page cache activity to be loggged.

from vB_Cache
logCacheActivity()

If cache logging is enabled this function writes the activity for this page to the database.

from vB_Cache
getSize($data)

No description

from vB_Cache
mixed
getEventTime(string $event)

Returns the UNIX timestamp of the last ocurrence of $event, and FALSE if there isn't one

setEventTime(string $event, int $time)

Store event in XCache

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 61
protected __construct($cachetype)

Constructor protected to enforce singleton use.

Parameters

$cachetype

See also

instance()

in vB_Cache at line 176
static getDefaults()

Get the cache defaults.

at line 85
static vB_Cache instance($type = NULL)

Returns singleton instance of self.

Parameters

$type

Return Value

vB_Cache
  • Reference to instance of the cache handler

in vB_Cache at line 237
static resetCache($expiredOnly = false)

Parameters

$expiredOnly

in vB_Cache at line 252
static resetAllCache($expiredOnly = false)

Parameters

$expiredOnly

in vB_Cache at line 287
string write($key, $data, $lifetime_mins = false, $events = false)

Writes data as a cache object.

A string key is required to uniquely identify a cache object. Client code should add all information that would affect the individualisation of the cache object to the key.

If lifetime_mins is supplied the cache object will be purged the next time it is read after the TTL has passed.

If a cache object should be purged on triggered events then events should be supplied as an array of string id's of the form 'scope.event', for example 'widget55.updated' may be used to purge a cache of a defined widget with the id 55 when it is reconfigured.

Parameters

$key
$data
$lifetime_mins
$events

Return Value

string | bool - Cache id or false

at line 133
protected writeCache(array $cache)

Writes the cache data to storage.

Parameters

array $cache includes key, data, expires

in vB_Cache at line 346
saveCacheInfo($cacheid)

Based on the assumption that if we go back to a page we're likely to request a lot of the information we requested last time we were on that page, let's store the cached information.

Parameters

$cacheid

in vB_Cache at line 406
restoreCacheInfo($cacheid)

If we used saveCacheInfo to save data, this will get it back.

**

Parameters

$cacheid

in vB_Cache at line 433
bool isLoaded(string $key)

has a value been loaded for this key?

Parameters

string $key the key

Return Value

bool

in vB_Cache at line 464
mixed readSingle($key, $write_lock = false, $save_meta = false)

Reads a cache object and returns the data.

Integrity checking should be performed by the client code, ensuring that the returned data is in the expected form.

$key should be a string key with all of the identifying information for the required cache objects. This must match the $key used to write the cache object.

The implicit lock can be set to true to indicate that the client code will rebuild the cache on an expired read. This allows cache handlers to lock the cache for the current connection. Normally, if a cache entry is locked then subsequent reads should return the expired cache data until it is unlocked. This cannot be done for cache entries that don't yet exist, but can be used on existing entries to prevent cache slams - where multiple connections decide to rebuild the cache under a race condition.

Cache handlers should ensure to implement an expiration on cache locks.

Parameters

$key
$write_lock
$save_meta

Return Value

mixed
  • The cached data (string or array of strings) or boolean false

See also

cache::Write()

at line 177
protected array readCache(string $key)

Reads the cache object from storage.

Parameters

string $key
  • Identifying key

Return Value

array includes key, data, expires

in vB_Cache at line 524
purge($cacheid)

Purges a cache object.

Parameters

$cacheid

at line 225
protected purgeCache(int $key)

Removes a cache object from storage.

Parameters

int $key
  • Key of the cache entry to purge

in vB_Cache at line 551
expire(int/array $cache_ids)

Expires a cache object.

This is preferred to purging a cache entry as it ensures that that the cache data can still be served while new cache data is being rebuilt.

Parameters

int/array $cache_ids
  • Id of the cache entry to expire

at line 240
protected bool expireCache($keys)

Sets a cache entry as expired in storage.

Parameters

$keys

Return Value

bool

at line 270
event(string $events)

Expires cache objects based on a triggered event.

An event handling vB_CacheObserver must be attached to handle cache events. Generally the CacheObservers would respond by calling vB_Cache::expire() with the cache_id's of the objects to expire.

Parameters

string $events | array $event - The name of the event

in vB_Cache at line 590
static allCacheEvent($events)

Parameters

$events

at line 296
bool lock(string $key)

Locks a cache entry.

Parameters

string $key
  • Key of the cache entry to lock

Return Value

bool
  • TRUE iff the lock was obtained

at line 303
unlock($key)

Unlocks a cache entry.

Most implementations may unlock the cache during write, making this redundant.

Parameters

$key

at line 315
clean(bool $only_expired = true)

Cleans cache.

Parameters

bool $only_expired
  • Only clean expired entries

at line 337
shutdown()

in vB_Cache at line 651
cleanNow()

Tells the cache to trigger all events.

in vB_Cache at line 670
array read(string $keys, bool $writeLock = false, bool $save_meta = false)

Reads an array of cache objects from storage.

Parameters

string $keys
  • Ids of the cache entry to read
bool $writeLock whether to lock the values
bool $save_meta whether to save this cache id and preload the value for the page next time.

Return Value

array of array includes key, data, expires

in vB_Cache at line 795
updateTime($time = false)

This updates the time. It is useful only for testing. Otherwise it does nothing

@param integer timestamp- optional

Parameters

$time

in vB_Cache at line 811
static protected logCacheAction($cacheid, $action, $type = 4, $size = 0)

If cache logging is enabled this stores the page cache activity to be loggged.

Parameters

$cacheid
$action
$type
$size

in vB_Cache at line 870
protected logCacheActivity()

If cache logging is enabled this function writes the activity for this page to the database.

in vB_Cache at line 908
protected getSize($data)

Parameters

$data

at line 102
protected mixed getEventTime(string $event)

Returns the UNIX timestamp of the last ocurrence of $event, and FALSE if there isn't one

Parameters

string $event

Return Value

mixed

at line 113
protected setEventTime(string $event, int $time)

Store event in XCache

Parameters

string $event
  • Event identifier
int $time
  • If 0, the event won't overwrite any XCache entry