|
| __construct (array $options=[]) |
|
| save ($data, $id, $tags=[], $specificLifetime=false) |
|
| load ($id, $doNotTestCacheValidity=false) |
|
| __construct (array $options=array()) |
|
| load ($id, $doNotTestCacheValidity=false) |
|
| test ($id) |
|
| save ($data, $id, $tags=array(), $specificLifetime=false) |
|
| remove ($id) |
|
| clean ($mode=Zend_Cache::CLEANING_MODE_ALL, $tags=array()) |
|
| isAutomaticCleaningAvailable () |
|
| setDirectives ($directives) |
|
| getIds () |
|
| getTags () |
|
| getIdsMatchingTags ($tags=array()) |
|
| getIdsNotMatchingTags ($tags=array()) |
|
| getIdsMatchingAnyTags ($tags=array()) |
|
| getFillingPercentage () |
|
| getMetadatas ($id) |
|
| touch ($id, $extraLifetime) |
|
| getCapabilities () |
|
| __construct (array $options=array()) |
|
| setDirectives ($directives) |
|
| setOption ($name, $value) |
|
| getOption ($name) |
|
| getLifetime ($specificLifetime) |
|
| isAutomaticCleaningAvailable () |
|
| getTmpDir () |
|
Definition at line 8 of file Memcached.php.
◆ __construct()
__construct |
( |
array |
$options = [] | ) |
|
Constructor
- Parameters
-
- See also
- \Zend_Cache_Backend_Memcached::__construct()
- Exceptions
-
Definition at line 26 of file Memcached.php.
32 throw new \Magento\Framework\Exception\LocalizedException(
34 "Invalid value for the node <slab_size>. Expected to be positive integer." 41 $this->_options[
'slab_size'] =
$options[
'slab_size'];
◆ _cleanTheMess()
_cleanTheMess |
( |
|
$id, |
|
|
|
$chunks |
|
) |
| |
|
protected |
Remove saved chunks in case something gone wrong (e.g. some chunk from the chain can not be found)
- Parameters
-
string | $id | ID of data's info cell |
int | $chunks | Number of chunks to remove (basically, the number after '{splitted}|') |
- Returns
- null
Definition at line 64 of file Memcached.php.
66 for (
$i = 0;
$i < $chunks;
$i++) {
◆ _getChunkId()
_getChunkId |
( |
|
$id, |
|
|
|
$index |
|
) |
| |
|
protected |
Returns ID of a specific chunk on the basis of data's ID
- Parameters
-
string | $id | Main data's ID |
int | $index | Particular chunk number to return ID for |
- Returns
- string
Definition at line 52 of file Memcached.php.
54 return "{$id}[{$index}]";
◆ load()
load |
( |
|
$id, |
|
|
|
$doNotTestCacheValidity = false |
|
) |
| |
Load data from memcached, glue from several chunks if it was splitted upon save.
- Parameters
-
- See also
- \Zend_Cache_Backend_Memcached::load()
- Parameters
-
bool | $doNotTestCacheValidity | |
- See also
- \Zend_Cache_Backend_Memcached::load()
- Returns
- bool|false|string
Implements Zend_Cache_Backend_Interface.
Definition at line 109 of file Memcached.php.
111 $data = parent::load(
$id, $doNotTestCacheValidity);
113 if (is_string(
$data) && substr(
$data, 0, strlen(self::CODE_WORD)) == self::CODE_WORD) {
116 $arr = explode(
'|',
$data);
117 $chunks = isset($arr[1]) ? $arr[1] :
false;
120 if ($chunks && is_numeric($chunks)) {
121 for (
$i = 0;
$i < $chunks;
$i++) {
122 $chunk = parent::load($this->
_getChunkId(
$id,
$i), $doNotTestCacheValidity);
124 if (
false === $chunk) {
132 $chunkData[] = $chunk;
135 return implode(
'', $chunkData);
_cleanTheMess($id, $chunks)
◆ save()
save |
( |
|
$data, |
|
|
|
$id, |
|
|
|
$tags = [] , |
|
|
|
$specificLifetime = false |
|
) |
| |
Save data to memcached, split it into chunks if data size is bigger than memcached slab size.
- Parameters
-
- See also
- \Zend_Cache_Backend_Memcached::save()
- Parameters
-
- See also
- \Zend_Cache_Backend_Memcached::save()
- Parameters
-
- See also
- \Zend_Cache_Backend_Memcached::save()
- Parameters
-
- See also
- \Zend_Cache_Backend_Memcached::save()
- Returns
- bool
Implements Zend_Cache_Backend_Interface.
Definition at line 82 of file Memcached.php.
84 if (is_string(
$data) && strlen(
$data) > $this->_options[
'slab_size']) {
85 $dataChunks = str_split(
$data, $this->_options[
'slab_size']);
87 for (
$i = 0, $cnt = count($dataChunks);
$i < $cnt;
$i++) {
90 if (!parent::save($dataChunks[
$i], $chunkId, $tags, $specificLifetime)) {
96 $data = self::CODE_WORD .
'|' .
$i;
99 return parent::save(
$data,
$id, $tags, $specificLifetime);
_cleanTheMess($id, $chunks)
◆ CODE_WORD
const CODE_WORD = '{splitted}' |
Used to tell chunked data from ordinary
Definition at line 18 of file Memcached.php.
◆ DEFAULT_SLAB_SIZE
const DEFAULT_SLAB_SIZE = 1048576 |
Maximum chunk of data that could be saved in one memcache cell (1 MiB)
Definition at line 13 of file Memcached.php.
The documentation for this class was generated from the following file: