Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/flow-flo.../libs/cakephp/cache/Engine
File: MemcachedEngine.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
[2] Fix | Delete
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[3] Fix | Delete
*
[4] Fix | Delete
* Licensed under The MIT License
[5] Fix | Delete
* For full copyright and license information, please see the LICENSE.txt
[6] Fix | Delete
* Redistributions of files must retain the above copyright notice.
[7] Fix | Delete
*
[8] Fix | Delete
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[9] Fix | Delete
* @link https://cakephp.org CakePHP(tm) Project
[10] Fix | Delete
* @since 2.5.0
[11] Fix | Delete
* @license https://opensource.org/licenses/mit-license.php MIT License
[12] Fix | Delete
*/
[13] Fix | Delete
namespace Cake\Cache\Engine;
[14] Fix | Delete
[15] Fix | Delete
use Cake\Cache\CacheEngine;
[16] Fix | Delete
use InvalidArgumentException;
[17] Fix | Delete
use Memcached;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Memcached storage engine for cache. Memcached has some limitations in the amount of
[21] Fix | Delete
* control you have over expire times far in the future. See MemcachedEngine::write() for
[22] Fix | Delete
* more information.
[23] Fix | Delete
*
[24] Fix | Delete
* Memcached engine supports binary protocol and igbinary
[25] Fix | Delete
* serialization (if memcached extension is compiled with --enable-igbinary).
[26] Fix | Delete
* Compressed keys can also be incremented/decremented.
[27] Fix | Delete
*/
[28] Fix | Delete
class MemcachedEngine extends CacheEngine
[29] Fix | Delete
{
[30] Fix | Delete
/**
[31] Fix | Delete
* memcached wrapper.
[32] Fix | Delete
*
[33] Fix | Delete
* @var \Memcached
[34] Fix | Delete
*/
[35] Fix | Delete
protected $_Memcached;
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* The default config used unless overridden by runtime configuration
[39] Fix | Delete
*
[40] Fix | Delete
* - `compress` Whether to compress data
[41] Fix | Delete
* - `duration` Specify how long items in this cache configuration last.
[42] Fix | Delete
* - `groups` List of groups or 'tags' associated to every key stored in this config.
[43] Fix | Delete
* handy for deleting a complete group from cache.
[44] Fix | Delete
* - `username` Login to access the Memcache server
[45] Fix | Delete
* - `password` Password to access the Memcache server
[46] Fix | Delete
* - `persistent` The name of the persistent connection. All configurations using
[47] Fix | Delete
* the same persistent value will share a single underlying connection.
[48] Fix | Delete
* - `prefix` Prepended to all entries. Good for when you need to share a keyspace
[49] Fix | Delete
* with either another cache config or another application.
[50] Fix | Delete
* - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable
[51] Fix | Delete
* cache::gc from ever being called automatically.
[52] Fix | Delete
* - `serialize` The serializer engine used to serialize data. Available engines are php,
[53] Fix | Delete
* igbinary and json. Beside php, the memcached extension must be compiled with the
[54] Fix | Delete
* appropriate serializer support.
[55] Fix | Delete
* - `servers` String or array of memcached servers. If an array MemcacheEngine will use
[56] Fix | Delete
* them as a pool.
[57] Fix | Delete
* - `options` - Additional options for the memcached client. Should be an array of option => value.
[58] Fix | Delete
* Use the \Memcached::OPT_* constants as keys.
[59] Fix | Delete
*
[60] Fix | Delete
* @var array
[61] Fix | Delete
*/
[62] Fix | Delete
protected $_defaultConfig = [
[63] Fix | Delete
'compress' => false,
[64] Fix | Delete
'duration' => 3600,
[65] Fix | Delete
'groups' => [],
[66] Fix | Delete
'host' => null,
[67] Fix | Delete
'username' => null,
[68] Fix | Delete
'password' => null,
[69] Fix | Delete
'persistent' => false,
[70] Fix | Delete
'port' => null,
[71] Fix | Delete
'prefix' => 'cake_',
[72] Fix | Delete
'probability' => 100,
[73] Fix | Delete
'serialize' => 'php',
[74] Fix | Delete
'servers' => ['127.0.0.1'],
[75] Fix | Delete
'options' => [],
[76] Fix | Delete
];
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* List of available serializer engines
[80] Fix | Delete
*
[81] Fix | Delete
* Memcached must be compiled with json and igbinary support to use these engines
[82] Fix | Delete
*
[83] Fix | Delete
* @var array
[84] Fix | Delete
*/
[85] Fix | Delete
protected $_serializers = [];
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* @var string[]
[89] Fix | Delete
*/
[90] Fix | Delete
protected $_compiledGroupNames = [];
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Initialize the Cache Engine
[94] Fix | Delete
*
[95] Fix | Delete
* Called automatically by the cache frontend
[96] Fix | Delete
*
[97] Fix | Delete
* @param array $config array of setting for the engine
[98] Fix | Delete
* @return bool True if the engine has been successfully initialized, false if not
[99] Fix | Delete
* @throws \InvalidArgumentException When you try use authentication without
[100] Fix | Delete
* Memcached compiled with SASL support
[101] Fix | Delete
*/
[102] Fix | Delete
public function init(array $config = [])
[103] Fix | Delete
{
[104] Fix | Delete
if (!extension_loaded('memcached')) {
[105] Fix | Delete
return false;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
$this->_serializers = [
[109] Fix | Delete
'igbinary' => Memcached::SERIALIZER_IGBINARY,
[110] Fix | Delete
'json' => Memcached::SERIALIZER_JSON,
[111] Fix | Delete
'php' => Memcached::SERIALIZER_PHP,
[112] Fix | Delete
];
[113] Fix | Delete
if (defined('Memcached::HAVE_MSGPACK') && Memcached::HAVE_MSGPACK) {
[114] Fix | Delete
$this->_serializers['msgpack'] = Memcached::SERIALIZER_MSGPACK;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
parent::init($config);
[118] Fix | Delete
[119] Fix | Delete
if (!empty($config['host'])) {
[120] Fix | Delete
if (empty($config['port'])) {
[121] Fix | Delete
$config['servers'] = [$config['host']];
[122] Fix | Delete
} else {
[123] Fix | Delete
$config['servers'] = [sprintf('%s:%d', $config['host'], $config['port'])];
[124] Fix | Delete
}
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
if (isset($config['servers'])) {
[128] Fix | Delete
$this->setConfig('servers', $config['servers'], false);
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
if (!is_array($this->_config['servers'])) {
[132] Fix | Delete
$this->_config['servers'] = [$this->_config['servers']];
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
if (isset($this->_Memcached)) {
[136] Fix | Delete
return true;
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
if ($this->_config['persistent']) {
[140] Fix | Delete
$this->_Memcached = new Memcached((string)$this->_config['persistent']);
[141] Fix | Delete
} else {
[142] Fix | Delete
$this->_Memcached = new Memcached();
[143] Fix | Delete
}
[144] Fix | Delete
$this->_setOptions();
[145] Fix | Delete
[146] Fix | Delete
if (count($this->_Memcached->getServerList())) {
[147] Fix | Delete
return true;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
$servers = [];
[151] Fix | Delete
foreach ($this->_config['servers'] as $server) {
[152] Fix | Delete
$servers[] = $this->parseServerString($server);
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
if (!$this->_Memcached->addServers($servers)) {
[156] Fix | Delete
return false;
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
if (is_array($this->_config['options'])) {
[160] Fix | Delete
foreach ($this->_config['options'] as $opt => $value) {
[161] Fix | Delete
$this->_Memcached->setOption($opt, $value);
[162] Fix | Delete
}
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
if (empty($this->_config['username']) && !empty($this->_config['login'])) {
[166] Fix | Delete
throw new InvalidArgumentException(
[167] Fix | Delete
'Please pass "username" instead of "login" for connecting to Memcached'
[168] Fix | Delete
);
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
if ($this->_config['username'] !== null && $this->_config['password'] !== null) {
[172] Fix | Delete
if (!method_exists($this->_Memcached, 'setSaslAuthData')) {
[173] Fix | Delete
throw new InvalidArgumentException(
[174] Fix | Delete
'Memcached extension is not built with SASL support'
[175] Fix | Delete
);
[176] Fix | Delete
}
[177] Fix | Delete
$this->_Memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
[178] Fix | Delete
$this->_Memcached->setSaslAuthData(
[179] Fix | Delete
$this->_config['username'],
[180] Fix | Delete
$this->_config['password']
[181] Fix | Delete
);
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
return true;
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
/**
[188] Fix | Delete
* Settings the memcached instance
[189] Fix | Delete
*
[190] Fix | Delete
* @return void
[191] Fix | Delete
* @throws \InvalidArgumentException When the Memcached extension is not built
[192] Fix | Delete
* with the desired serializer engine.
[193] Fix | Delete
*/
[194] Fix | Delete
protected function _setOptions()
[195] Fix | Delete
{
[196] Fix | Delete
$this->_Memcached->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
[197] Fix | Delete
[198] Fix | Delete
$serializer = strtolower($this->_config['serialize']);
[199] Fix | Delete
if (!isset($this->_serializers[$serializer])) {
[200] Fix | Delete
throw new InvalidArgumentException(
[201] Fix | Delete
sprintf('%s is not a valid serializer engine for Memcached', $serializer)
[202] Fix | Delete
);
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
if (
[206] Fix | Delete
$serializer !== 'php' &&
[207] Fix | Delete
!constant('Memcached::HAVE_' . strtoupper($serializer))
[208] Fix | Delete
) {
[209] Fix | Delete
throw new InvalidArgumentException(
[210] Fix | Delete
sprintf('Memcached extension is not compiled with %s support', $serializer)
[211] Fix | Delete
);
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
$this->_Memcached->setOption(
[215] Fix | Delete
Memcached::OPT_SERIALIZER,
[216] Fix | Delete
$this->_serializers[$serializer]
[217] Fix | Delete
);
[218] Fix | Delete
[219] Fix | Delete
// Check for Amazon ElastiCache instance
[220] Fix | Delete
if (
[221] Fix | Delete
defined('Memcached::OPT_CLIENT_MODE') &&
[222] Fix | Delete
defined('Memcached::DYNAMIC_CLIENT_MODE')
[223] Fix | Delete
) {
[224] Fix | Delete
$this->_Memcached->setOption(
[225] Fix | Delete
Memcached::OPT_CLIENT_MODE,
[226] Fix | Delete
Memcached::DYNAMIC_CLIENT_MODE
[227] Fix | Delete
);
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
$this->_Memcached->setOption(
[231] Fix | Delete
Memcached::OPT_COMPRESSION,
[232] Fix | Delete
(bool)$this->_config['compress']
[233] Fix | Delete
);
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
/**
[237] Fix | Delete
* Parses the server address into the host/port. Handles both IPv6 and IPv4
[238] Fix | Delete
* addresses and Unix sockets
[239] Fix | Delete
*
[240] Fix | Delete
* @param string $server The server address string.
[241] Fix | Delete
* @return array Array containing host, port
[242] Fix | Delete
*/
[243] Fix | Delete
public function parseServerString($server)
[244] Fix | Delete
{
[245] Fix | Delete
$socketTransport = 'unix://';
[246] Fix | Delete
if (strpos($server, $socketTransport) === 0) {
[247] Fix | Delete
return [substr($server, strlen($socketTransport)), 0];
[248] Fix | Delete
}
[249] Fix | Delete
if (substr($server, 0, 1) === '[') {
[250] Fix | Delete
$position = strpos($server, ']:');
[251] Fix | Delete
if ($position !== false) {
[252] Fix | Delete
$position++;
[253] Fix | Delete
}
[254] Fix | Delete
} else {
[255] Fix | Delete
$position = strpos($server, ':');
[256] Fix | Delete
}
[257] Fix | Delete
$port = 11211;
[258] Fix | Delete
$host = $server;
[259] Fix | Delete
if ($position !== false) {
[260] Fix | Delete
$host = substr($server, 0, $position);
[261] Fix | Delete
$port = substr($server, $position + 1);
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
return [$host, (int)$port];
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Backwards compatible alias of parseServerString
[269] Fix | Delete
*
[270] Fix | Delete
* @param string $server The server address string.
[271] Fix | Delete
* @return array Array containing host, port
[272] Fix | Delete
* @deprecated 3.4.13 Will be removed in 4.0.0
[273] Fix | Delete
*/
[274] Fix | Delete
protected function _parseServerString($server)
[275] Fix | Delete
{
[276] Fix | Delete
return $this->parseServerString($server);
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
/**
[280] Fix | Delete
* Read an option value from the memcached connection.
[281] Fix | Delete
*
[282] Fix | Delete
* @param string $name The option name to read.
[283] Fix | Delete
* @return string|int|bool|null
[284] Fix | Delete
*/
[285] Fix | Delete
public function getOption($name)
[286] Fix | Delete
{
[287] Fix | Delete
return $this->_Memcached->getOption($name);
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
/**
[291] Fix | Delete
* Write data for key into cache. When using memcached as your cache engine
[292] Fix | Delete
* remember that the Memcached pecl extension does not support cache expiry
[293] Fix | Delete
* times greater than 30 days in the future. Any duration greater than 30 days
[294] Fix | Delete
* will be treated as real Unix time value rather than an offset from current time.
[295] Fix | Delete
*
[296] Fix | Delete
* @param string $key Identifier for the data
[297] Fix | Delete
* @param mixed $value Data to be cached
[298] Fix | Delete
* @return bool True if the data was successfully cached, false on failure
[299] Fix | Delete
* @see https://www.php.net/manual/en/memcached.set.php
[300] Fix | Delete
*/
[301] Fix | Delete
public function write($key, $value)
[302] Fix | Delete
{
[303] Fix | Delete
$duration = $this->_config['duration'];
[304] Fix | Delete
$key = $this->_key($key);
[305] Fix | Delete
[306] Fix | Delete
return $this->_Memcached->set($key, $value, $duration);
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
/**
[310] Fix | Delete
* Write many cache entries to the cache at once
[311] Fix | Delete
*
[312] Fix | Delete
* @param array $data An array of data to be stored in the cache
[313] Fix | Delete
* @return array of bools for each key provided, true if the data was
[314] Fix | Delete
* successfully cached, false on failure
[315] Fix | Delete
*/
[316] Fix | Delete
public function writeMany($data)
[317] Fix | Delete
{
[318] Fix | Delete
$cacheData = [];
[319] Fix | Delete
foreach ($data as $key => $value) {
[320] Fix | Delete
$cacheData[$this->_key($key)] = $value;
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
$success = $this->_Memcached->setMulti($cacheData);
[324] Fix | Delete
[325] Fix | Delete
$return = [];
[326] Fix | Delete
foreach (array_keys($data) as $key) {
[327] Fix | Delete
$return[$key] = $success;
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
return $return;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
/**
[334] Fix | Delete
* Read a key from the cache
[335] Fix | Delete
*
[336] Fix | Delete
* @param string $key Identifier for the data
[337] Fix | Delete
* @return mixed The cached data, or false if the data doesn't exist, has
[338] Fix | Delete
* expired, or if there was an error fetching it.
[339] Fix | Delete
*/
[340] Fix | Delete
public function read($key)
[341] Fix | Delete
{
[342] Fix | Delete
$key = $this->_key($key);
[343] Fix | Delete
[344] Fix | Delete
return $this->_Memcached->get($key);
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
/**
[348] Fix | Delete
* Read many keys from the cache at once
[349] Fix | Delete
*
[350] Fix | Delete
* @param array $keys An array of identifiers for the data
[351] Fix | Delete
* @return array An array containing, for each of the given $keys, the cached data or
[352] Fix | Delete
* false if cached data could not be retrieved.
[353] Fix | Delete
*/
[354] Fix | Delete
public function readMany($keys)
[355] Fix | Delete
{
[356] Fix | Delete
$cacheKeys = [];
[357] Fix | Delete
foreach ($keys as $key) {
[358] Fix | Delete
$cacheKeys[] = $this->_key($key);
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
$values = $this->_Memcached->getMulti($cacheKeys);
[362] Fix | Delete
$return = [];
[363] Fix | Delete
foreach ($keys as &$key) {
[364] Fix | Delete
$return[$key] = array_key_exists($this->_key($key), $values) ?
[365] Fix | Delete
$values[$this->_key($key)] : false;
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
return $return;
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* Increments the value of an integer cached key
[373] Fix | Delete
*
[374] Fix | Delete
* @param string $key Identifier for the data
[375] Fix | Delete
* @param int $offset How much to increment
[376] Fix | Delete
* @return int|false New incremented value, false otherwise
[377] Fix | Delete
*/
[378] Fix | Delete
public function increment($key, $offset = 1)
[379] Fix | Delete
{
[380] Fix | Delete
$key = $this->_key($key);
[381] Fix | Delete
[382] Fix | Delete
return $this->_Memcached->increment($key, $offset);
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
/**
[386] Fix | Delete
* Decrements the value of an integer cached key
[387] Fix | Delete
*
[388] Fix | Delete
* @param string $key Identifier for the data
[389] Fix | Delete
* @param int $offset How much to subtract
[390] Fix | Delete
* @return int|false New decremented value, false otherwise
[391] Fix | Delete
*/
[392] Fix | Delete
public function decrement($key, $offset = 1)
[393] Fix | Delete
{
[394] Fix | Delete
$key = $this->_key($key);
[395] Fix | Delete
[396] Fix | Delete
return $this->_Memcached->decrement($key, $offset);
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
/**
[400] Fix | Delete
* Delete a key from the cache
[401] Fix | Delete
*
[402] Fix | Delete
* @param string $key Identifier for the data
[403] Fix | Delete
* @return bool True if the value was successfully deleted, false if it didn't
[404] Fix | Delete
* exist or couldn't be removed.
[405] Fix | Delete
*/
[406] Fix | Delete
public function delete($key)
[407] Fix | Delete
{
[408] Fix | Delete
$key = $this->_key($key);
[409] Fix | Delete
[410] Fix | Delete
return $this->_Memcached->delete($key);
[411] Fix | Delete
}
[412] Fix | Delete
[413] Fix | Delete
/**
[414] Fix | Delete
* Delete many keys from the cache at once
[415] Fix | Delete
*
[416] Fix | Delete
* @param array $keys An array of identifiers for the data
[417] Fix | Delete
* @return array of boolean values that are true if the key was successfully
[418] Fix | Delete
* deleted, false if it didn't exist or couldn't be removed.
[419] Fix | Delete
*/
[420] Fix | Delete
public function deleteMany($keys)
[421] Fix | Delete
{
[422] Fix | Delete
$cacheKeys = [];
[423] Fix | Delete
foreach ($keys as $key) {
[424] Fix | Delete
$cacheKeys[] = $this->_key($key);
[425] Fix | Delete
}
[426] Fix | Delete
[427] Fix | Delete
$success = $this->_Memcached->deleteMulti($cacheKeys);
[428] Fix | Delete
[429] Fix | Delete
$return = [];
[430] Fix | Delete
foreach ($keys as $key) {
[431] Fix | Delete
$return[$key] = $success;
[432] Fix | Delete
}
[433] Fix | Delete
[434] Fix | Delete
return $return;
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
/**
[438] Fix | Delete
* Delete all keys from the cache
[439] Fix | Delete
*
[440] Fix | Delete
* @param bool $check If true will check expiration, otherwise delete all.
[441] Fix | Delete
* @return bool True if the cache was successfully cleared, false otherwise
[442] Fix | Delete
*/
[443] Fix | Delete
public function clear($check)
[444] Fix | Delete
{
[445] Fix | Delete
if ($check) {
[446] Fix | Delete
return true;
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
$keys = $this->_Memcached->getAllKeys();
[450] Fix | Delete
if ($keys === false) {
[451] Fix | Delete
return false;
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
foreach ($keys as $key) {
[455] Fix | Delete
if (strpos($key, $this->_config['prefix']) === 0) {
[456] Fix | Delete
$this->_Memcached->delete($key);
[457] Fix | Delete
}
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
return true;
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
/**
[464] Fix | Delete
* Add a key to the cache if it does not already exist.
[465] Fix | Delete
*
[466] Fix | Delete
* @param string $key Identifier for the data.
[467] Fix | Delete
* @param mixed $value Data to be cached.
[468] Fix | Delete
* @return bool True if the data was successfully cached, false on failure.
[469] Fix | Delete
*/
[470] Fix | Delete
public function add($key, $value)
[471] Fix | Delete
{
[472] Fix | Delete
$duration = $this->_config['duration'];
[473] Fix | Delete
$key = $this->_key($key);
[474] Fix | Delete
[475] Fix | Delete
return $this->_Memcached->add($key, $value, $duration);
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
/**
[479] Fix | Delete
* Returns the `group value` for each of the configured groups
[480] Fix | Delete
* If the group initial value was not found, then it initializes
[481] Fix | Delete
* the group accordingly.
[482] Fix | Delete
*
[483] Fix | Delete
* @return string[]
[484] Fix | Delete
*/
[485] Fix | Delete
public function groups()
[486] Fix | Delete
{
[487] Fix | Delete
if (empty($this->_compiledGroupNames)) {
[488] Fix | Delete
foreach ($this->_config['groups'] as $group) {
[489] Fix | Delete
$this->_compiledGroupNames[] = $this->_config['prefix'] . $group;
[490] Fix | Delete
}
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
$groups = $this->_Memcached->getMulti($this->_compiledGroupNames) ?: [];
[494] Fix | Delete
if (count($groups) !== count($this->_config['groups'])) {
[495] Fix | Delete
foreach ($this->_compiledGroupNames as $group) {
[496] Fix | Delete
if (!isset($groups[$group])) {
[497] Fix | Delete
$this->_Memcached->set($group, 1, 0);
[498] Fix | Delete
$groups[$group] = 1;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function