lithium\storage\cache\adapter\Memcache::key()
Overrides
lithium\storage\cache\Adapter::key()
Generates safe cache keys.
As per the protocol no control characters or whitespace is allowed in the key name. There's also a limit of max. 250 characters which is checked and enforced here. The limit is actually lowered to 250 minus the length of an crc32b hash minus separator (241) minus scope length minus separator (241 - x).
Parameters
-
array
$keys
The original keys.
Returns
arrayKeys modified and safe to use with adapter.
Source
public function key(array $keys) {
$length = 241 - ($this->_config['scope'] ? strlen($this->_config['scope']) + 1 : 0);
return array_map(
function($key) use ($length) {
$result = substr(preg_replace('/[[:cntrl:]\s]/u', '_', $key), 0, $length);
return $key !== $result ? $result . '_' . hash('crc32b', $key) : $result;
},
$keys
);
}