SlaxWeb Framework
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Attributes | List of all members
SlaxWeb\Cache\Manager Class Reference

Public Member Functions

 __construct (AbstractHandler $handler)
 
 write (string $name, $data, int $maxAge=-1)
 
 read (string $name)
 
 remove (string $name, bool $partial=false)
 

Protected Attributes

 $handler = null
 

Constructor & Destructor Documentation

SlaxWeb\Cache\Manager::__construct ( AbstractHandler  $handler)

Constructor

Class constructor copies the dependencies to the class properties. The Cache Manager depends on the cache handler object, and uses it throughout its execution to write and read from the cache.

Parameters
\SlaxWeb\Cache\AbstractHandler$handlerCache handler object

Member Function Documentation

SlaxWeb\Cache\Manager::read ( string  $name)

Read

Reads the data from the cache and returns. If the data has expired, it will automatically remove the expired data from the cache. It does not handle any handler thrown exceptions, and simply returns that what it receives.

Parameters
string$nameName of the data stored in cache
Returns
mixed
SlaxWeb\Cache\Manager::remove ( string  $name,
bool  $partial = false 
)

Remove

Removes the data from the cache. No exceptions are handled that are thrown in the handler. It accepts the name of the cached data. If the second parameter is set to true, all cached data containing that name will be removed.

Parameters
string$nameName of the data stored in cache
bool$partialRemove all data containing '$name', default false
Returns
bool
SlaxWeb\Cache\Manager::write ( string  $name,
  $data,
int  $maxAge = -1 
)

Write

Serializes the data and writes it to cache using the handler. It accepts the name for the cached data as the first parameter, the data as the second parameter, and a maximum age value as the third parameter. If the maximum age is not supplied or is of a negative value, the configured default is used. If an error occurs when trying to write to cahce, bool(false) is returned, bool(true) otherwise.

Parameters
string$nameName of the data to be written to cache
mixed$dataData to be stored into the cache
int$maxAgeMaximum age for this specific data, default -1
Returns
bool

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