class RestfulStaticCacheController in RESTful 7
@file Contains RestfulStaticCacheController
Hierarchy
- class \RestfulStaticCacheController implements RestfulStaticCacheControllerInterface
Expanded class hierarchy of RestfulStaticCacheController
File
- includes/
RestfulStaticCacheController.php, line 8 - Contains RestfulStaticCacheController
View source
class RestfulStaticCacheController implements \RestfulStaticCacheControllerInterface {
/**
* @var array
*
* The cache ID registry.
*/
protected $cids = array();
/**
* @var string
*
* The cache key prefix.
*/
protected $prefix;
/**
* Constructor
*/
public function __construct() {
$this->prefix = 'restful_' . mt_rand() . '_';
}
/**
* {@inheritdoc}
*/
public function get($cid, $default = NULL) {
$this
->registerCid($cid);
return drupal_static($this->prefix . $cid, $default);
}
/**
* {@inheritdoc}
*/
public function set($cid, $value) {
$val =& drupal_static($this->prefix . $cid);
$val = $value;
}
/**
* {@inheritdoc}
*/
public function clear($cid) {
drupal_static_reset($this->prefix . $cid);
}
/**
* {@inheritdoc}
*/
public function clearAll() {
foreach ($this
->getCids() as $cid) {
$this
->clear($cid);
}
}
/**
* Register cache ID. The registry is used by clearAll.
*
* @param string $cid
* The cache ID to register.
*/
protected function registerCid($cid) {
if (!in_array($cid, $this->cids)) {
$this->cids[] = $cid;
}
}
/**
* Cache ID accessor.
*
* @return array
* The cache IDs.
*/
public function getCids() {
return $this->cids;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RestfulStaticCacheController:: |
protected | property | The cache ID registry. | |
RestfulStaticCacheController:: |
protected | property | The cache key prefix. | |
RestfulStaticCacheController:: |
public | function |
Clear a particular cache value. Overrides RestfulStaticCacheControllerInterface:: |
|
RestfulStaticCacheController:: |
public | function |
Clear all registered cache values. Overrides RestfulStaticCacheControllerInterface:: |
|
RestfulStaticCacheController:: |
public | function |
Gets the static cache. Overrides RestfulStaticCacheControllerInterface:: |
|
RestfulStaticCacheController:: |
public | function | Cache ID accessor. | |
RestfulStaticCacheController:: |
protected | function | Register cache ID. The registry is used by clearAll. | |
RestfulStaticCacheController:: |
public | function |
Sets the static cache. Overrides RestfulStaticCacheControllerInterface:: |
|
RestfulStaticCacheController:: |
public | function | Constructor |