mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-02 14:23:34 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -2,37 +2,36 @@
|
|||
/**
|
||||
* Memcache storage engine for cache
|
||||
*
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Cache.Engine
|
||||
* @since CakePHP(tm) v 1.2.0.4933
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Memcache storage engine for cache. Memcache has some limitations in the amount of
|
||||
* control you have over expire times far in the future. See MemcacheEngine::write() for
|
||||
* Memcache storage engine for cache. Memcache has some limitations in the amount of
|
||||
* control you have over expire times far in the future. See MemcacheEngine::write() for
|
||||
* more information.
|
||||
*
|
||||
* @package Cake.Cache.Engine
|
||||
* @package Cake.Cache.Engine
|
||||
* @deprecated 3.0.0 You should use the Memcached adapter instead.
|
||||
*/
|
||||
class MemcacheEngine extends CacheEngine {
|
||||
|
||||
/**
|
||||
* Contains the compiled group names
|
||||
* (prefixed witht the global configuration prefix)
|
||||
* (prefixed with the global configuration prefix)
|
||||
*
|
||||
* @var array
|
||||
**/
|
||||
*/
|
||||
protected $_compiledGroupNames = array();
|
||||
|
||||
/**
|
||||
|
@ -60,7 +59,7 @@ class MemcacheEngine extends CacheEngine {
|
|||
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
|
||||
*
|
||||
* @param array $settings array of setting for the engine
|
||||
* @return boolean True if the engine has been successfully initialized, false if not
|
||||
* @return bool True if the engine has been successfully initialized, false if not
|
||||
*/
|
||||
public function init($settings = array()) {
|
||||
if (!class_exists('Memcache')) {
|
||||
|
@ -98,17 +97,17 @@ class MemcacheEngine extends CacheEngine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses the server address into the host/port. Handles both IPv6 and IPv4
|
||||
* Parses the server address into the host/port. Handles both IPv6 and IPv4
|
||||
* addresses and Unix sockets
|
||||
*
|
||||
* @param string $server The server address string.
|
||||
* @return array Array containing host, port
|
||||
*/
|
||||
protected function _parseServerString($server) {
|
||||
if ($server[0] == 'u') {
|
||||
if (strpos($server, 'unix://') === 0) {
|
||||
return array($server, 0);
|
||||
}
|
||||
if (substr($server, 0, 1) == '[') {
|
||||
if (substr($server, 0, 1) === '[') {
|
||||
$position = strpos($server, ']:');
|
||||
if ($position !== false) {
|
||||
$position++;
|
||||
|
@ -126,14 +125,14 @@ class MemcacheEngine extends CacheEngine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Write data for key into cache. When using memcache as your cache engine
|
||||
* Write data for key into cache. When using memcache as your cache engine
|
||||
* remember that the Memcache pecl extension does not support cache expiry times greater
|
||||
* than 30 days in the future. Any duration greater than 30 days will be treated as never expiring.
|
||||
*
|
||||
* @param string $key Identifier for the data
|
||||
* @param mixed $value Data to be cached
|
||||
* @param integer $duration How long to cache the data, in seconds
|
||||
* @return boolean True if the data was successfully cached, false on failure
|
||||
* @param int $duration How long to cache the data, in seconds
|
||||
* @return bool True if the data was successfully cached, false on failure
|
||||
* @see http://php.net/manual/en/memcache.set.php
|
||||
*/
|
||||
public function write($key, $value, $duration) {
|
||||
|
@ -157,14 +156,14 @@ class MemcacheEngine extends CacheEngine {
|
|||
* Increments the value of an integer cached key
|
||||
*
|
||||
* @param string $key Identifier for the data
|
||||
* @param integer $offset How much to increment
|
||||
* @param int $offset How much to increment
|
||||
* @return New incremented value, false otherwise
|
||||
* @throws CacheException when you try to increment with compress = true
|
||||
*/
|
||||
public function increment($key, $offset = 1) {
|
||||
if ($this->settings['compress']) {
|
||||
throw new CacheException(
|
||||
__d('cake_dev', 'Method increment() not implemented for compressed cache in %s', __CLASS__)
|
||||
__d('cake_dev', 'Method %s not implemented for compressed cache in %s', 'increment()', __CLASS__)
|
||||
);
|
||||
}
|
||||
return $this->_Memcache->increment($key, $offset);
|
||||
|
@ -174,14 +173,14 @@ class MemcacheEngine extends CacheEngine {
|
|||
* Decrements the value of an integer cached key
|
||||
*
|
||||
* @param string $key Identifier for the data
|
||||
* @param integer $offset How much to subtract
|
||||
* @param int $offset How much to subtract
|
||||
* @return New decremented value, false otherwise
|
||||
* @throws CacheException when you try to decrement with compress = true
|
||||
*/
|
||||
public function decrement($key, $offset = 1) {
|
||||
if ($this->settings['compress']) {
|
||||
throw new CacheException(
|
||||
__d('cake_dev', 'Method decrement() not implemented for compressed cache in %s', __CLASS__)
|
||||
__d('cake_dev', 'Method %s not implemented for compressed cache in %s', 'decrement()', __CLASS__)
|
||||
);
|
||||
}
|
||||
return $this->_Memcache->decrement($key, $offset);
|
||||
|
@ -191,7 +190,7 @@ class MemcacheEngine extends CacheEngine {
|
|||
* Delete a key from the cache
|
||||
*
|
||||
* @param string $key Identifier for the data
|
||||
* @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
|
||||
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
|
||||
*/
|
||||
public function delete($key) {
|
||||
return $this->_Memcache->delete($key);
|
||||
|
@ -200,20 +199,21 @@ class MemcacheEngine extends CacheEngine {
|
|||
/**
|
||||
* Delete all keys from the cache
|
||||
*
|
||||
* @param boolean $check
|
||||
* @return boolean True if the cache was successfully cleared, false otherwise
|
||||
* @param bool $check If true no deletes will occur and instead CakePHP will rely
|
||||
* on key TTL values.
|
||||
* @return bool True if the cache was successfully cleared, false otherwise
|
||||
*/
|
||||
public function clear($check) {
|
||||
if ($check) {
|
||||
return true;
|
||||
}
|
||||
foreach ($this->_Memcache->getExtendedStats('slabs') as $slabs) {
|
||||
foreach ($this->_Memcache->getExtendedStats('slabs', 0) as $slabs) {
|
||||
foreach (array_keys($slabs) as $slabId) {
|
||||
if (!is_numeric($slabId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($this->_Memcache->getExtendedStats('cachedump', $slabId) as $stats) {
|
||||
foreach ($this->_Memcache->getExtendedStats('cachedump', $slabId, 0) as $stats) {
|
||||
if (!is_array($stats)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -232,8 +232,8 @@ class MemcacheEngine extends CacheEngine {
|
|||
* Connects to a server in connection pool
|
||||
*
|
||||
* @param string $host host ip address or name
|
||||
* @param integer $port Server port
|
||||
* @return boolean True if memcache server was connected
|
||||
* @param int $port Server port
|
||||
* @return bool True if memcache server was connected
|
||||
*/
|
||||
public function connect($host, $port = 11211) {
|
||||
if ($this->_Memcache->getServerStatus($host, $port) === 0) {
|
||||
|
@ -251,7 +251,7 @@ class MemcacheEngine extends CacheEngine {
|
|||
* the group accordingly.
|
||||
*
|
||||
* @return array
|
||||
**/
|
||||
*/
|
||||
public function groups() {
|
||||
if (empty($this->_compiledGroupNames)) {
|
||||
foreach ($this->settings['groups'] as $group) {
|
||||
|
@ -283,9 +283,30 @@ class MemcacheEngine extends CacheEngine {
|
|||
* Increments the group value to simulate deletion of all keys under a group
|
||||
* old values will remain in storage until they expire.
|
||||
*
|
||||
* @return boolean success
|
||||
**/
|
||||
* @param string $group The group to clear.
|
||||
* @return bool success
|
||||
*/
|
||||
public function clearGroup($group) {
|
||||
return (bool)$this->_Memcache->increment($this->settings['prefix'] . $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data for key into cache if it doesn't exist already. When using memcached as your cache engine
|
||||
* remember that the Memcached PECL extension does not support cache expiry times greater
|
||||
* than 30 days in the future. Any duration greater than 30 days will be treated as never expiring.
|
||||
* If it already exists, it fails and returns false.
|
||||
*
|
||||
* @param string $key Identifier for the data.
|
||||
* @param mixed $value Data to be cached.
|
||||
* @param int $duration How long to cache the data, in seconds.
|
||||
* @return bool True if the data was successfully cached, false on failure.
|
||||
* @link http://php.net/manual/en/memcache.add.php
|
||||
*/
|
||||
public function add($key, $value, $duration) {
|
||||
if ($duration > 30 * DAY) {
|
||||
$duration = 0;
|
||||
}
|
||||
|
||||
return $this->_Memcache->add($key, $value, $this->settings['compress'], $duration);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue