class vB_Cache_Memory extends vB_Cache

vB_Cache_Memory

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

Properties

static protected $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
protected $cache

Methods

__sleep()

No description

__wakeup()

No description

__construct($cachetype)

Constructor public to allow for separate automated unit testing. Actual code should use vB_Cache::instance();

static 
getDefaults()

Get the cache defaults.

from vB_Cache
static vB_Cache
instance($type = self::CACHE_STD)

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($cacheKey)

Removes a cache object from storage.

expire(int/array $cache_ids)

Expires a cache object.

from vB_Cache
bool
expireCache(string $key)

Sets a cache entry as expired in storage. But sine we don't store, that means do nothing

event(string $events)

This unsets a variable in the cache

static 
allCacheEvent($events)

No description

from vB_Cache
bool
lock(string $key)

Locks a cache entry.

unlock(mixed $keys)

Unlocks a cache entry.

from vB_Cache
clean(bool $only_expired = true)

Cleans cache.

shutdown()

No description

from vB_Cache
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
addEvents($key, $events)

No description

removeEvents($event)

No description

getLoadedValue($key)

No description

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 37
__construct($cachetype)

Constructor public to allow for separate automated unit testing. Actual code should use vB_Cache::instance();

Parameters

$cachetype

See also

vB_Cache::instance

in vB_Cache at line 176
static getDefaults()

Get the cache defaults.

at line 48
static vB_Cache instance($type = self::CACHE_STD)

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 63
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 144
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 224
protected purgeCache($cacheKey)

Removes a cache object from storage.

Parameters

$cacheKey

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 200
protected bool expireCache(string $key)

Sets a cache entry as expired in storage. But sine we don't store, that means do nothing

Parameters

string $key
  • Key of the cache entry to expire

Return Value

bool

at line 167
event(string $events)

This unsets a variable in the cache

Parameters

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

in vB_Cache at line 590
static allCacheEvent($events)

Parameters

$events

at line 208
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

in vB_Cache at line 620
unlock(mixed $keys)

Unlocks a cache entry.

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

Parameters

mixed $keys array of string $key - Identifying key

at line 245
clean(bool $only_expired = true)

Cleans cache.

Parameters

bool $only_expired
  • Only clean expired entries

in vB_Cache at line 640
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 111
addEvents($key, $events)

Parameters

$key
$events

at line 129
removeEvents($event)

Parameters

$event

at line 213
protected getLoadedValue($key)

Parameters

$key