\CJAX\CoreCache

The Cache class, stores a cache for AJAX request.

Summary

Methods
Properties
Constants
__construct()
getCache()
setCache()
get()
getId()
set()
append()
appendLast()
merge()
hasContents()
getContents()
read()
tap()
remove()
delete()
deleteLast()
flush()
flushAll()
$cache
$actions
$lastCache
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$caching
N/A

Properties

$cache

$cache : array

The cache property, stores a list of the actual cache content.

Type

array

$actions

$actions : array

The actions property, stores a list of the actions for caching.

Type

array

$lastCache

$lastCache : array

The lastCache property, holds cache set for to execute last. Use flag $ajax->flag('last'); to store commands.

This makes it so that commands even if called first can be executed last.

Type

array

$caching

$caching : boolean

The caching property, determines if caching is enabled.

Type

boolean

Methods

__construct()

__construct(boolean  $caching) : \CJAX\Core\Cache

The constructor for Cache class, creates an instance of Cache object.

Parameters

boolean $caching

Returns

\CJAX\Core\Cache

getCache()

getCache() : array

The getCache method, fetches the internal cache data array.

Returns

array

setCache()

setCache(array  $cache = array()) : array

The setCache method, overwrites the internal cache data array.

Parameters

array $cache

Returns

array

get()

get(integer  $cacheId) : mixed

The get method, obtains a cached data given its id.

Parameters

integer $cacheId

Returns

mixed

getId()

getId() : integer

The getId method, acquires the current cache Id for internal cache iterator.

Returns

integer

set()

set(integer  $cacheId, mixed  $value) : void

The set method, adds a given data to the cache given its id.

Parameters

integer $cacheId
mixed $value

append()

append(mixed  $value = null, integer|string  $cacheId = null) : void

The append method, appends a given cache to the end of cache.

If an optional value for cacheId is provided, it behaves the same as set method.

Parameters

mixed $value
integer|string $cacheId

appendLast()

appendLast(mixed  $add = null, integer  $cacheId = null) : void

The appendLast method, adds a given data to the last cache given its id.

Parameters

mixed $add
integer $cacheId

merge()

merge() : void

The merge method, merges the last cache into cache array.

hasContents()

hasContents() : boolean

The hasContents method, checks if there are contents stored in cache.

This method returns true if either cache or actions array contains data.

Returns

boolean

getContents()

getContents() : array

The getContents method, acquires all contents stored in cache.

Returns

array

read()

read(string  $crc32 = null) : mixed

The read method, read cached data stored previously in local disk.

Parameters

string $crc32

Returns

mixed

tap()

tap(string  $crc32) : mixed

The tap method, fetches cache stored in memory or on local disk.

Parameters

string $crc32

Returns

mixed

remove()

remove(integer  $cacheId) : void

The remove method, removes a given cache from storage given its id.

If the cached data is an array, this method will reduce it to an empty array.

Parameters

integer $cacheId

delete()

delete(integer  $cacheId = null) : void

The delete method, deletes a given cache from storage given its id.

Different from remove method, it completely get rids of specified data.

Parameters

integer $cacheId

deleteLast()

deleteLast(integer  $count) : void

The deleteLast method, deletes the last cache from storage.

Parameters

integer $count

flush()

flush() : void

The flush method, flushes and clears the internal cached data.

flushAll()

flushAll() : void

The flushAll method, flushes and empties all stored data.