class vB_Cache_Null extends vB_Cache

Null Cache.

Handler that just does nothing. Mostly needed for installer/upgrader

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 vB_Cache $instance A reference to the singleton instance from vB_Cache
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 vB_dB_Assertor $assertor
protected requestStart $requestStart
protected $cache

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 = self::CACHE_STD)

Returns an instance of the global cache.

from vB_Cache
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.

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.

restoreCacheInfo($cacheid)

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

bool
isLoaded(string $key)

has a value been loaded for this key?

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

Purges a cache object.

purgeCache($key)

Removes a cache object from storage.

expire($cache_id)

Expires a cache object.

bool
expireCache($key)

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($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.

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

Reads an array of cache objects from storage.

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
attachObserver(vB_Cache_Observer $observer)

No description

removeObserver(vB_Cache_Observer $observer)

No description

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 47
__construct($cachetype)

Constructor protected to enforce singleton use.

Parameters

$cachetype

in vB_Cache at line 176
static getDefaults()

Get the cache defaults.

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

Returns an instance of the global cache.

The cache type used is defined in options.

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

at line 61
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 52
protected writeCache(array $cache)

Writes the cache data to storage.

Parameters

array $cache includes key, data, expires

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

at line 71
restoreCacheInfo($cacheid)

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

**

Parameters

$cacheid

at line 76
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 54
protected array readCache(string $key)

Reads the cache object from storage.

Parameters

string $key
  • Identifying key

Return Value

array includes key, data, expires

at line 86
purge($cache_id)

Purges a cache object.

Parameters

$cache_id

at line 56
protected purgeCache($key)

Removes a cache object from storage.

Parameters

$key

at line 91
expire($cache_id)

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

$cache_id

at line 58
protected bool expireCache($key)

Sets a cache entry as expired in storage.

Parameters

$key

Return Value

bool

at line 96
event(string $events)

Expires cache objects based on a triggered event.

Parameters

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

in vB_Cache at line 590
static allCacheEvent($events)

Parameters

$events

at line 101
bool lock($key)

Locks a cache entry.

This is done to prevent a cache slam where concurrent connections attempt to rebuild an expired cache entry. While a cache entry is locked, it should be considered valid and served to all connections except the one that has the lock. After the cache entry has been rebuilt it will be unlocked, allowing all new connections to consume the fresh entry.

Parameters

$key

Return Value

bool
  • TRUE iff the lock was obtained

at line 106
unlock($key)

Unlocks a cache entry.

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

Parameters

$key

at line 113
clean(bool $only_expired = true)

Cleans cache.

$created_before should be a unix timestamp.

Parameters

bool $only_expired
  • Only clean expired entries

at line 122
shutdown()

at line 124
cleanNow()

Tells the cache to trigger all events.

at line 81
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 116
attachObserver(vB_Cache_Observer $observer)

Parameters

vB_Cache_Observer $observer

at line 118
removeObserver(vB_Cache_Observer $observer)

Parameters

vB_Cache_Observer $observer