vBulletin 5.6.5 API

vB_Cache_Memcached extends vB_Cache
in package

Memcached.

Handler that caches and retrieves data from the memcache.

Tags
see
vB_Cache

Table of Contents

CACHE_FAST  = 1
CACHE_LARGE  = 2
CACHE_LOG_CLEAR  = 6
CACHE_LOG_HASVALUE  = 4
CACHE_LOG_NOVALUE  = 5
CACHE_LOG_READFAIL  = 3
CACHE_LOG_READSUCCESS  = 2
CACHE_LOG_WRITE  = 1
CACHE_STD  = 0
EVENT_PREFIX  = '~ev_'
GLOBAL_EVENT  = 'global_cache_clear'
LOCK_PREFIX  = 'lock_'
$actions  : mixed
$cacheLogging  : mixed
$cachetype  : string
Cache type of current object.
$disableCache  : mixed
$events  : mixed
$instance  : vB_Cache_Memcached
A reference to the singleton instance
$keys_used  : mixed
$memcached  : vB_Memcache
The Memcached wrapper
$meta_info  : mixed
$meta_loaded  : mixed
$metadata_life  : mixed
$metadata_update_min  : mixed
$no_values  : mixed
$noCache  : mixed
$prefix  : string
Unique prefix for item's title, required for multiple forums on the same server using the same classes that read/write to memory
$timeNow  : mixed
The current time - this is used a lot so let's make it a member variable.
$values_read  : mixed
__serialize()  : mixed
__sleep()  : mixed
__unserialize()  : mixed
__wakeup()  : mixed
allCacheEvent()  : mixed
clean()  : mixed
Cleans cache.
cleanNow()  : mixed
Tells the cache to trigger all events.
event()  : mixed
Expires cache objects based on a triggered event.
expire()  : mixed
Expires a cache object.
getContextKey()  : vB_Context
Get a context key
getDefaults()  : mixed
Get the cache defaults.
instance()  : vB_Cache_Memcached
Returns singleton instance of self.
isLoaded()  : bool
has a value been loaded for this key?
lock()  : bool
Locks a cache entry.
purge()  : mixed
Purges a cache object.
read()  : array<string|int, mixed>
Reads an array of cache objects from storage.
readSingle()  : mixed
Reads a cache object and returns the data.
resetAllCache()  : mixed
resetCache()  : mixed
restoreCacheInfo()  : mixed
If we used saveCacheInfo to save data, this will get it back.
saveCacheInfo()  : mixed
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.
shutdown()  : mixed
unlock()  : mixed
Unlocks a cache entry.
updateTime()  : mixed
This updates the time. It is useful only for testing. Otherwise it does nothing
write()  : string
Writes data as a cache object.
__construct()  : mixed
Constructor protected to enforce singleton use.
expireCache()  : array<string|int, mixed>
Sets a cache entry as expired in storage.
getEventTime()  : mixed
Returns the UNIX timestamp of the last ocurrence of $event, and FALSE if there isn't one
getEventTimes()  : mixed
Returns the UNIX timestamp of the last ocurrence of $events. If there was none the return for that key will be missing.
getSize()  : mixed
logCacheAction()  : mixed
If cache logging is enabled this stores the page cache activity to be loggged.
logCacheActivity()  : mixed
If cache logging is enabled this function writes the activity for this page to the database.
purgeCache()  : bool
Removes a cache object from storage.
readCache()  : array<string|int, mixed>
Reads the cache object from storage.
readCacheArray()  : array<string|int, mixed>
Reads an array of cache objects from storage.
setEventTime()  : mixed
Store event in memcache
writeCache()  : mixed
Writes the cache data to storage.
addKeyToEvent()  : mixed

Constants

CACHE_FAST

public mixed CACHE_FAST = 1

CACHE_LARGE

public mixed CACHE_LARGE = 2

CACHE_LOG_CLEAR

public mixed CACHE_LOG_CLEAR = 6

CACHE_LOG_HASVALUE

public mixed CACHE_LOG_HASVALUE = 4

CACHE_LOG_NOVALUE

public mixed CACHE_LOG_NOVALUE = 5

CACHE_LOG_READFAIL

public mixed CACHE_LOG_READFAIL = 3

CACHE_LOG_READSUCCESS

public mixed CACHE_LOG_READSUCCESS = 2

CACHE_LOG_WRITE

public mixed CACHE_LOG_WRITE = 1

CACHE_STD

public mixed CACHE_STD = ""

EVENT_PREFIX

public mixed EVENT_PREFIX = '~ev_'

GLOBAL_EVENT

public mixed GLOBAL_EVENT = 'global_cache_clear'

LOCK_PREFIX

public mixed LOCK_PREFIX = 'lock_'

Properties

$actions

protected static mixed $actions = array(self::CACHE_STD => array(), self::CACHE_FAST => array(), self::CACHE_LARGE => array(), 4 => array())

$cacheLogging

protected static mixed $cacheLogging = alse

$cachetype

Cache type of current object.

protected string $cachetype

$disableCache

protected static mixed $disableCache = alse

$keys_used

protected mixed $keys_used

$meta_info

protected mixed $meta_info = alse

$meta_loaded

protected mixed $meta_loaded = alse

$metadata_life

protected mixed $metadata_life = 1440

$metadata_update_min

protected mixed $metadata_update_min = 5

$no_values

protected mixed $no_values = array()

$noCache

protected mixed $noCache = alse

$prefix

Unique prefix for item's title, required for multiple forums on the same server using the same classes that read/write to memory

protected string $prefix = ''

$timeNow

The current time - this is used a lot so let's make it a member variable.

protected mixed $timeNow

$values_read

protected mixed $values_read = array()

Methods

__serialize()

public __serialize() : mixed
Return values
mixed

__sleep()

public __sleep() : mixed
Return values
mixed

__unserialize()

public __unserialize(mixed $serialized) : mixed
Parameters
$serialized : mixed
Return values
mixed

__wakeup()

public __wakeup() : mixed
Return values
mixed

allCacheEvent()

public static allCacheEvent(mixed $events) : mixed
Parameters
$events : mixed
Return values
mixed

clean()

Cleans cache.

public clean([bool $only_expired = true ]) : mixed
Parameters
$only_expired : bool = true
  • Only clean expired entries
Return values
mixed

cleanNow()

Tells the cache to trigger all events.

public cleanNow() : mixed
Return values
mixed

event()

Expires cache objects based on a triggered event.

public event(mixed $events) : mixed

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
$events : mixed
Return values
mixed

expire()

Expires a cache object.

public expire(mixed $cache_ids) : mixed

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
$cache_ids : mixed
Return values
mixed

getContextKey()

Get a context key

public getContextKey(string $prefix, array<string|int, mixed> $values) : vB_Context

This is intended to generate a cache key from complex information, particularly arrays which affect the generation of the cached data. The end result will is not guarenteed to be particular readable (and most likely isn't) but it should be unique to that combination of params.

Parameters
$prefix : string

-- Human readable string to prefix the cachekey. intended to help debugging by allowing inspection to understand where that key came from.

$values : array<string|int, mixed>

-- array/value pairs to encode into the key. Order doesn't matter since they will be sorted on key generation.

Return values
vB_Context

getDefaults()

Get the cache defaults.

public static getDefaults() : mixed
Return values
mixed

instance()

Returns singleton instance of self.

public static instance([mixed $type = NULL ]) : vB_Cache_Memcached
Parameters
$type : mixed = NULL
Tags
todo

This can be inherited once late static binding is available. For now it has to be redefined in the child classes

Return values
vB_Cache_Memcached
  • Reference to singleton instance of cache handler

isLoaded()

has a value been loaded for this key?

public isLoaded(mixed $key) : bool
Parameters
$key : mixed
Return values
bool

lock()

Locks a cache entry.

public lock(string $key) : bool
Parameters
$key : string
  • Key of the cache entry to lock
Return values
bool
  • TRUE iff the lock was obtained

purge()

Purges a cache object.

public purge(mixed $cacheid) : mixed
Parameters
$cacheid : mixed
Return values
mixed

read()

Reads an array of cache objects from storage.

public read(string $keys[, mixed $writeLock = false ][, mixed $save_meta = false ]) : array<string|int, mixed>
Parameters
$keys : string
  • Ids of the cache entry to read
$writeLock : mixed = false
$save_meta : mixed = false
Return values
array<string|int, mixed>

of array includes key, data, expires

readSingle()

Reads a cache object and returns the data.

public readSingle(mixed $key[, bool &$write_lock = false ][, mixed $save_meta = false ]) : mixed

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 : mixed
  • Identifying key. String or array of strings
$write_lock : bool = false
  • Whether a failed read implies a lock for writing
$save_meta : mixed = false
Tags
see
cache::Write()
Return values
mixed
  • The cached data (string or array of strings) or boolean false

resetAllCache()

public static resetAllCache([mixed $expiredOnly = false ]) : mixed
Parameters
$expiredOnly : mixed = false
Return values
mixed

resetCache()

public static resetCache([mixed $expiredOnly = false ]) : mixed
Parameters
$expiredOnly : mixed = false
Return values
mixed

restoreCacheInfo()

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

public restoreCacheInfo(mixed $cacheid) : mixed
Parameters
$cacheid : mixed
Return values
mixed

saveCacheInfo()

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.

public saveCacheInfo(mixed $cacheid) : mixed
Parameters
$cacheid : mixed
Return values
mixed

shutdown()

public shutdown() : mixed
Return values
mixed

unlock()

Unlocks a cache entry.

public unlock(mixed $key) : mixed

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

Parameters
$key : mixed
Return values
mixed

updateTime()

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

public updateTime([mixed $time = false ]) : mixed
@param	integer		timestamp- optional
Parameters
$time : mixed = false
Return values
mixed

write()

Writes data as a cache object.

public write(string $key, mixed $data[, mixed $lifetime_mins = false ][, mixed $events = false ]) : string

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 : string
  • Identifying key
$data : mixed
  • Data to cache
$lifetime_mins : mixed = false
$events : mixed = false
Return values
string

| bool - Cache id or false

__construct()

Constructor protected to enforce singleton use.

protected __construct(mixed $cachetype) : mixed
Parameters
$cachetype : mixed
Tags
see
instance()
Return values
mixed

expireCache()

Sets a cache entry as expired in storage.

protected expireCache(mixed $keys) : array<string|int, mixed>
Parameters
$keys : mixed
Return values
array<string|int, mixed>

of killed items

getEventTime()

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

protected getEventTime(string $event) : mixed
Parameters
$event : string
Return values
mixed

getEventTimes()

Returns the UNIX timestamp of the last ocurrence of $events. If there was none the return for that key will be missing.

protected getEventTimes(mixed $events) : mixed
Parameters
$events : mixed
Return values
mixed

array of either FALSE or int

getSize()

protected getSize(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

logCacheAction()

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

protected static logCacheAction(mixed $cacheid, mixed $action[, mixed $type = 4 ], mixed $size) : mixed
Parameters
$cacheid : mixed
$action : mixed
$type : mixed = 4
$size : mixed
Return values
mixed

logCacheActivity()

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

protected logCacheActivity() : mixed
Return values
mixed

purgeCache()

Removes a cache object from storage.

protected purgeCache(int $key) : bool
Parameters
$key : int
  • Key of the cache entry to purge
Return values
bool
  • Whether anything was purged

readCache()

Reads the cache object from storage.

protected readCache(string $key) : array<string|int, mixed>
Parameters
$key : string
  • Id of the cache entry to read
Return values
array<string|int, mixed>

includes key, data, expires

readCacheArray()

Reads an array of cache objects from storage.

protected readCacheArray(mixed $keys[, mixed $writeLock = false ]) : array<string|int, mixed>
Parameters
$keys : mixed
$writeLock : mixed = false
Return values
array<string|int, mixed>

of array includes key, data, expires

setEventTime()

Store event in memcache

protected setEventTime(string $event, int $time) : mixed
Parameters
$event : string
  • Event identifier
$time : int
  • If 0, the event won't overwrite any memcache entry
Return values
mixed

writeCache()

Writes the cache data to storage.

protected writeCache(mixed $cache) : mixed
Parameters
$cache : mixed
Return values
mixed

addKeyToEvent()

private addKeyToEvent(mixed $event, mixed $key) : mixed
Parameters
$event : mixed
$key : mixed
Return values
mixed

Search results