Skip to content
Snippets Groups Projects
Commit a5313d6a authored by catch's avatar catch
Browse files

Issue #1808112 by sun: Fixed Missing method visibility, bogus phpDoc and...

Issue #1808112 by sun: Fixed Missing method visibility, bogus phpDoc and coding style in Cache backend classes.
parent 716e8a83
No related branches found
No related tags found
No related merge requests found
......@@ -38,8 +38,8 @@
* To access your custom cache bin, specify the name of the bin when storing
* or retrieving cached data:
* @code
* cache_set($cid, $data, 'custom_bin', $expire);
* cache_get($cid, 'custom_bin');
* cache('custom_bin')->set($cid, $data, $expire);
* cache('custom_bin')->get($cid);
* @endcode
*
* @see cache()
......@@ -60,7 +60,7 @@ interface CacheBackendInterface {
* @param $bin
* The cache bin for which the object is created.
*/
function __construct($bin);
public function __construct($bin);
/**
* Returns data from the persistent cache.
......@@ -74,7 +74,7 @@ function __construct($bin);
* @return
* The cache or FALSE on failure.
*/
function get($cid);
public function get($cid);
/**
* Returns data from the persistent cache when given an array of cache IDs.
......@@ -87,7 +87,7 @@ function get($cid);
* @return
* An array of the items successfully returned from cache indexed by cid.
*/
function getMultiple(&$cids);
public function getMultiple(&$cids);
/**
* Stores data in the persistent cache.
......@@ -111,7 +111,7 @@ function getMultiple(&$cids);
* a node, both the node ID and the author's user ID might be passed in as
* tags. For example array('node' => array(123), 'user' => array(92)).
*/
function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array());
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array());
/**
* Deletes an item from the cache.
......@@ -119,7 +119,7 @@ function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, arra
* @param $cid
* The cache ID to delete.
*/
function delete($cid);
public function delete($cid);
/**
* Deletes multiple items from the cache.
......@@ -127,17 +127,17 @@ function delete($cid);
* @param $cids
* An array of $cids to delete.
*/
function deleteMultiple(Array $cids);
public function deleteMultiple(Array $cids);
/**
* Flushes all cache items in a bin.
*/
function flush();
public function flush();
/**
* Expires temporary items from the cache.
*/
function expire();
public function expire();
/**
* Invalidates each tag in the $tags array.
......@@ -148,12 +148,12 @@ function expire();
*
* @see CacheBackendInterface::set()
*/
function invalidateTags(array $tags);
public function invalidateTags(array $tags);
/**
* Performs garbage collection on a cache bin.
*/
function garbageCollection();
public function garbageCollection();
/**
* Checks if a cache bin is empty.
......@@ -164,5 +164,5 @@ function garbageCollection();
* @return
* TRUE if the cache bin specified is empty.
*/
function isEmpty();
public function isEmpty();
}
......@@ -31,7 +31,7 @@ class DatabaseBackend implements CacheBackendInterface {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::__construct().
*/
function __construct($bin) {
public function __construct($bin) {
// All cache tables should be prefixed with 'cache_', except for the
// default 'cache' bin.
if ($bin != 'cache') {
......@@ -43,7 +43,7 @@ function __construct($bin) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::get().
*/
function get($cid) {
public function get($cid) {
$cids = array($cid);
$cache = $this->getMultiple($cids);
return reset($cache);
......@@ -52,7 +52,7 @@ function get($cid) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
*/
function getMultiple(&$cids) {
public function getMultiple(&$cids) {
try {
// When serving cached pages, the overhead of using ::select() was found
// to add around 30% overhead to the request. Since $this->bin is a
......@@ -93,8 +93,6 @@ function getMultiple(&$cids) {
* valid item to load.
*/
protected function prepareItem($cache) {
global $user;
if (!isset($cache->data)) {
return FALSE;
}
......@@ -118,7 +116,7 @@ protected function prepareItem($cache) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/
function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
$fields = array(
'serialized' => 0,
'created' => REQUEST_TIME,
......@@ -149,7 +147,7 @@ function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, arra
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::delete().
*/
function delete($cid) {
public function delete($cid) {
Database::getConnection()->delete($this->bin)
->condition('cid', $cid)
->execute();
......@@ -158,7 +156,7 @@ function delete($cid) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
*/
function deleteMultiple(array $cids) {
public function deleteMultiple(array $cids) {
// Delete in chunks when a large array is passed.
do {
Database::getConnection()->delete($this->bin)
......@@ -171,14 +169,14 @@ function deleteMultiple(array $cids) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::flush().
*/
function flush() {
public function flush() {
Database::getConnection()->truncate($this->bin)->execute();
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::expire().
*/
function expire() {
public function expire() {
Database::getConnection()->delete($this->bin)
->condition('expire', CacheBackendInterface::CACHE_PERMANENT, '<>')
->condition('expire', REQUEST_TIME, '<')
......@@ -188,7 +186,7 @@ function expire() {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
*/
function garbageCollection() {
public function garbageCollection() {
$this->expire();
}
......@@ -196,9 +194,9 @@ function garbageCollection() {
* Compares two checksums of tags. Used to determine whether to serve a cached
* item or treat it as invalidated.
*
* @param integer @checksum
* @param integer $checksum
* The initial checksum to compare against.
* @param array @tags
* @param array $tags
* An array of tags to calculate a checksum for.
*
* @return boolean
......@@ -214,7 +212,7 @@ protected function validTags($checksum, array $tags) {
* @param array $tags
* Associative array of tags to flatten.
*
* @return
* @return array
* Numeric array of flattened tag identifiers.
*/
protected function flattenTags(array $tags) {
......@@ -288,7 +286,7 @@ protected function checksumTags($tags) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::isEmpty().
*/
function isEmpty() {
public function isEmpty() {
$this->garbageCollection();
$query = Database::getConnection()->select($this->bin);
$query->addExpression('1');
......
......@@ -36,26 +36,26 @@ class InstallBackend extends DatabaseBackend {
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::get().
*/
function get($cid) {
public function get($cid) {
return FALSE;
}
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::getMultiple().
*/
function getMultiple(&$cids) {
public function getMultiple(&$cids) {
return array();
}
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::set().
*/
function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::delete().
*/
function delete($cid) {
public function delete($cid) {
try {
if (class_exists('Drupal\Core\Database\Database')) {
parent::delete($cid);
......@@ -67,7 +67,7 @@ function delete($cid) {
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::deleteMultiple().
*/
function deleteMultiple(array $cids) {
public function deleteMultiple(array $cids) {
try {
if (class_exists('Drupal\Core\Database\Database')) {
parent::deleteMultiple($cids);
......@@ -79,7 +79,7 @@ function deleteMultiple(array $cids) {
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::invalidateTags().
*/
function invalidateTags(array $tags) {
public function invalidateTags(array $tags) {
try {
if (class_exists('Drupal\Core\Database\Database')) {
parent::invalidateTags($tags);
......@@ -91,7 +91,7 @@ function invalidateTags(array $tags) {
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::flush().
*/
function flush() {
public function flush() {
try {
if (class_exists('Drupal\Core\Database\Database')) {
parent::flush();
......@@ -103,7 +103,7 @@ function flush() {
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::expire().
*/
function expire() {
public function expire() {
try {
if (class_exists('Drupal\Core\Database\Database')) {
parent::expire();
......@@ -115,7 +115,7 @@ function expire() {
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::garbageCollection().
*/
function garbageCollection() {
public function garbageCollection() {
try {
if (class_exists('Drupal\Core\Database\Database')) {
parent::garbageCollection();
......@@ -127,7 +127,7 @@ function garbageCollection() {
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::isEmpty().
*/
function isEmpty() {
public function isEmpty() {
try {
if (class_exists('Drupal\Core\Database\Database')) {
return parent::isEmpty();
......
......@@ -105,13 +105,13 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN
);
}
/*
/**
* Calculates a checksum so data can be invalidated using tags.
*/
function checksum($tags) {
$checksum = "";
public function checksum($tags) {
$checksum = '';
foreach($tags as $tag) {
foreach ($tags as $tag) {
// Has the tag already been invalidated.
if (isset($this->invalidatedTags[$tag])) {
$checksum = $checksum . $tag . ':' . $this->invalidatedTags[$tag];
......@@ -201,8 +201,7 @@ protected function flattenTags(array $tags) {
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateTags().
*/
public function invalidateTags(array $tags) {
$flat_tags = $this->flattenTags($tags);
foreach($flat_tags as $tag) {
foreach ($this->flattenTags($tags) as $tag) {
if (isset($this->invalidatedTags[$tag])) {
$this->invalidatedTags[$tag] = $this->invalidatedTags[$tag] + 1;
}
......
......@@ -23,51 +23,51 @@ class NullBackend implements CacheBackendInterface {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::__construct().
*/
function __construct($bin) {}
public function __construct($bin) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::get().
*/
function get($cid) {
public function get($cid) {
return FALSE;
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
*/
function getMultiple(&$cids) {
public function getMultiple(&$cids) {
return array();
}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/
function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::delete().
*/
function delete($cid) {}
public function delete($cid) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
*/
function deleteMultiple(array $cids) {}
public function deleteMultiple(array $cids) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::flush().
*/
function flush() {}
public function flush() {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::expire().
*/
function expire() {}
public function expire() {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
*/
function garbageCollection() {}
public function garbageCollection() {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::invalidateTags().
......@@ -77,7 +77,7 @@ public function invalidateTags(array $tags) {}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::isEmpty().
*/
function isEmpty() {
public function isEmpty() {
return TRUE;
}
}
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\system\Tests\Cache\ArrayBackendUnitTest.
* Definition of Drupal\system\Tests\Cache\MemoryBackendUnitTest.
*/
namespace Drupal\system\Tests\Cache;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment