SlaxWeb Framework
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SlaxWeb\Cache\AbstractHandler Class Reference
Inheritance diagram for SlaxWeb\Cache\AbstractHandler:
Inheritance graph
[legend]

Public Member Functions

 write (string $name, string $data, int $maxAge=-1)
 
 exists (string $name)
 
 get (string $name)
 
 remove (string $name, bool $partial=false)
 

Protected Member Functions

 prepData (string $data, int $maxAge=-1)
 
 checkData (string $serialized)
 

Protected Attributes

 $maxAge = 0
 

Member Function Documentation

SlaxWeb\Cache\AbstractHandler::checkData ( string  $serialized)
protected

Check data

Unserializes, checks the data and returns it. If the data is malformed or expired an exception is thrown.

Parameters
string$serializedSerialized data
Returns
array
Exceptions
SlaxWeb if cached data is malformed
SlaxWeb if cached data has expired
SlaxWeb\Cache\AbstractHandler::exists ( string  $name)
abstract

Data exists

Checks if the data exists in the cache and retuns a bool value.

Parameters
string$nameData name
Returns
bool
SlaxWeb\Cache\AbstractHandler::get ( string  $name)
abstract

Get data

Gets the data from the cache based on the received name. If data is not found, an exception is thrown.

Parameters
string$nameData name
Returns
string
Exceptions
SlaxWeb if cached data not found
SlaxWeb\Cache\AbstractHandler::prepData ( string  $data,
int  $maxAge = -1 
)
protected

Prepare data

Prepares the data for writting into cache. Adds the required timestamps, the actual data, and max age, and returns it all as a serialized array. If he method retrieves a maximum age value as second parameter it will use it instead of the default.

Parameters
string$dataUser data for caching
int$maxAgeMaximum age in seconds, default -1
Returns
string
SlaxWeb\Cache\AbstractHandler::remove ( string  $name,
bool  $partial = false 
)
abstract

Remove data

Removes the data from the cached based on the received name. If data is not found, an exception is thrown. If the second parameter is set to true, all cached data containing that name will be removed.

Parameters
string$nameData name
bool$partialRemove all data containing '$name', default false
Returns
bool
Exceptions
SlaxWeb if cached data not found
SlaxWeb\Cache\AbstractHandler::write ( string  $name,
string  $data,
int  $maxAge = -1 
)
abstract

Write

Write data to cache with the given name and data. The data must be in the string format.

Parameters
string$nameData name
string$dataData to cache
int$maxAgeMaximum age in seconds, default -1
Returns
self
Exceptions
SlaxWeb if an error occurs writting to cache

The documentation for this class was generated from the following file: