vB_Cache_Memory
        
        extends vB_Cache
    
    
            
            in package
            
        
    
    
    
vB_Cache_Memory
Tags
Table of Contents
Constants
- 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
Methods
- __construct() : mixed
- Constructor public to allow for separate automated unit testing. Actual code should use vB_Cache::instance();
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- addEvents() : mixed
- allCacheEvent() : mixed
- clean() : mixed
- Cleans cache.
- cleanNow() : mixed
- Tells the cache to trigger all events.
- event() : mixed
- This unsets a variable in the cache
- expire() : mixed
- Expires a cache object.
- getContextKey() : vB_Context
- Get a context key
- getDefaults() : mixed
- Get the cache defaults.
- instance() : vB_Cache_Memory
- 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.
- removeEvents() : mixed
- 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.
- write() : string|bool
- Writes data as a cache object.
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
    = 0
    
    
    
    
Methods
__construct()
Constructor public to allow for separate automated unit testing. Actual code should use vB_Cache::instance();
    public
                    __construct(mixed $cachetype) : mixed
    Parameters
- $cachetype : mixed
Tags
__serialize()
    public
                    __serialize() : array<string|int, mixed>
    Return values
array<string|int, mixed>__sleep()
    public
                    __sleep() : array<string|int, mixed>
    Return values
array<string|int, mixed>__unserialize()
    public
                    __unserialize(array<string|int, mixed> $serialized) : void
    Parameters
- $serialized : array<string|int, mixed>
__wakeup()
    public
                    __wakeup() : void
    addEvents()
    public
                    addEvents(mixed $key, mixed $events) : mixed
    Parameters
- $key : mixed
- $events : mixed
allCacheEvent()
    public
            static        allCacheEvent(mixed $events) : mixed
    Parameters
- $events : mixed
clean()
Cleans cache.
    public
                    clean([bool $only_expired = true ]) : mixed
    Parameters
- $only_expired : bool = true
- 
                    - Only clean expired entries
 
cleanNow()
Tells the cache to trigger all events.
    public
                    cleanNow() : mixed
    event()
This unsets a variable in the cache
    public
                    event(mixed $events) : mixed
    Parameters
- $events : mixed
expire()
Expires a cache object.
    public
                    expire(int $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 : int
- 
                    - Id of the cache entry to expire
 
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_ContextgetDefaults()
Get the cache defaults.
    public
            static        getDefaults() : mixed
    instance()
Returns singleton instance of self.
    public
            static        instance([mixed $type = self::CACHE_STD ]) : vB_Cache_Memory
    Parameters
- $type : mixed = self::CACHE_STD
Return values
vB_Cache_Memory —- Reference to singleton instance of the cache handler
isLoaded()
has a value been loaded for this key?
    public
                    isLoaded(mixed $key) : bool
    Parameters
- $key : mixed
Return values
boollock()
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
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
Return values
mixed —- The cached data (string or array of strings) or boolean false
removeEvents()
    public
                    removeEvents(mixed $event) : mixed
    Parameters
- $event : mixed
resetAllCache()
    public
            static        resetAllCache([mixed $expiredOnly = false ]) : mixed
    Parameters
- $expiredOnly : mixed = false
resetCache()
    public
            static        resetCache([mixed $expiredOnly = false ]) : mixed
    Parameters
- $expiredOnly : mixed = false
restoreCacheInfo()
If we used saveCacheInfo to save data, this will get it back.
    public
                    restoreCacheInfo(mixed $cacheid) : mixed
    Parameters
- $cacheid : 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
shutdown()
    public
                    shutdown() : mixed
    unlock()
Unlocks a cache entry.
    public
                    unlock(mixed $keys) : mixed
    Most implementations may unlock the cache during write, making this redundant.
Parameters
- $keys : mixed
write()
Writes data as a cache object.
    public
                    write(string $key, mixed $data[, mixed $lifetime_mins = false ][, mixed $events = false ]) : string|bool
    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