Answer the question
In order to leave comments, you need to log in
How to make Zend\Cache\Storage\Adapter\Filesystem work with multiple keys?
You need to implement the following behavior:
$cache->setItem(array('key1', 'key2', 'key3'), 'value');
$cache->getItem('key1');
$cache->getItem('key2');
$cache->getItem('key3');
Answer the question
In order to leave comments, you need to log in
Keep the list of keys separately and cache by the main key.
$allKeys = array(
'Page' => array('page1', 'page2', ...),
);
function getKey($searchKey){
foreach($allKeys as $mainKey => $keys){
if (array_key_exists($searchKey, $keys[$mainKey])){
return $keys[$maintKey][$searchKey];
}
return null;
}
}
$key = getKey('page1');// or getKey('page2') // return Page
$cache->getItem($key);
I think this is an unusual task. So write a function:
function setItems($arr, $value) {
for($key in $arr) {
$cache->setItem($key, $value);
}
}
setItem(['key1', 'key2'], 'value');
$cache->getItem('key1') == $cache->getItem('key2'); # true
And, in general, reconsider your architecture.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question