\andrewsaudercacheSys

Summary

Methods
Properties
Constants
get()
put()
deleteCachedCategory()
deleteCachedItem()
deleteCachedItems()
deleteAllCache()
sanitizeKey()
$basepath
$debug
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$basepath

$basepath : 

Type

$debug

$debug : 

Type

Methods

get()

get(string  $cacheName, string  $key, integer  $maxAge = false) : string

Retrieves cached data based on the cache name and key requested. By default cache does not expire.

Example Usage:

$htmlToDisplay = cacheSys::get('outputHTMLCategory', md5('filenameOutputKey'));

if($htmlToDisplay===false) { //perform resource intensive logic here, eventually saving the output or data to the cache }

echo $htmlToDisplay;

Parameters

string $cacheName

any alpha-numeric string. used to categorize cache types.

string $key

any alpha-numeric string unique within the cache category.

integer $maxAge

how old a cache file is allowed to be (in seconds)

Returns

string —

the contents of the cache category/key combo. FALSE if the cache is not found.

put()

put(string  $cacheName, string  $key, string  $content) : boolean

Stores content in the cache. uses the category and key variables to enable retreival

Example Usage:

$htmlToDisplay = cacheSys::put('outputHTMLCategory', md5('filenameOutputKey'), 'content to store');

if($htmlToDisplay===false) { //perform resource intensive logic here, eventually saving the output or data to the cache }

echo $htmlToDisplay;

Parameters

string $cacheName

any alpha-numeric string. used to categorize cache types.

string $key

any alpha-numeric string unique within the cache category.

string $content

any string to store in the cache

Returns

boolean —

returns true if successful

deleteCachedCategory()

deleteCachedCategory(string  $category) : boolean

Deletes all cached copies of items within a specified category.

Example Usage:

$cacheDeleted = cacheSys::deleteCachedCategory('outputHTMLCategory');

Parameters

string $category

any alpha-numeric string used to categorize cache types.

Returns

boolean —

returns true if cache stores were deleted, false if no cache stores exist

deleteCachedItem()

deleteCachedItem(string  $category, string  $key) : boolean

Delete a specified cached copy within a specified category.

Example Usage:

$cacheDeleted = cacheSys::deleteCachedItem('outputHTMLCategory', md5('filenameOutputKey'));

Parameters

string $category

any alpha-numeric string used to categorize cache types.

string $key

any alpha-numeric string used to uniquely identify the item to delete.

Returns

boolean —

returns true if a cached copy was deleted, false if no cache existed

deleteCachedItems()

deleteCachedItems(string  $category, string  $key = null) : boolean

Delete a cached files with a specfied string in the file name

Example Usage:

$cacheDeleted = cacheSys::deleteCachedItems('outputHTMLCategory', 'stringInFilename');

Parameters

string $category

any alpha-numeric string used to categorize cache types.

string $key

any alpha-numeric string used to uniquely identify the item to delete.

Returns

boolean —

returns true if a cached copy was deleted, false if no cache existed

deleteAllCache()

deleteAllCache() : boolean

Delete all cache copies stored by cacheSys

Example Usage:

$cacheDeleted = cacheSys::deleteAllCache();

Returns

boolean —

returns true if cached copies were deleted, false if no cache existed

sanitizeKey()

sanitizeKey(  $dirtyString) : string

Sanitize the cache file key

Example Usage:

$cacheKey = cacheSys::sanitizeKey( $dirtyString ); $body = cacheSys::get( 'output', $cacheKey );

Parameters

$dirtyString

Returns

string —

returns sanitized string