Closed convenient closed 1 year ago
I do apologise, seems i needed to strtoupper
the key 🤔
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
/** @var \Magento\Framework\App\CacheInterface $cache */
$cache = $obj->get(\Magento\Framework\App\CacheInterface::class);
/** @var \Magento\Framework\Cache\Core $lowLevelCache */
$lowLevelCache = $cache->getFrontend()->getLowLevelFrontend();
$key = strtoupper('SomeSillyKey');
$result = $cache->save('cache entry value ' . time(), $key, ['Fun_Tags', 'Here'], 123);
echo "save result: " . var_export($result, true) . PHP_EOL;
$readResult = $cache->load($key);
echo "read result: " . $readResult . PHP_EOL;
/** @var Cm_Cache_Backend_Redis $backend */
$backend = $lowLevelCache->getBackend();
echo "backend class: " . get_class($backend) . PHP_EOL;
echo "metadatas result from lowlevelcache: " . var_export($lowLevelCache->getMetadatas($key), true) . PHP_EOL;
echo "metadatas result from backend: " . var_export($backend->getMetadatas($key), true) . PHP_EOL;
save result: true
read result: cache entry value 1668695167
backend class: Cm_Cache_Backend_Redis
metadatas result from lowlevelcache: array (
'expire' => 1668695290,
'tags' =>
array (
0 => 'd1e_FUN_TAGS',
1 => 'd1e_HERE',
2 => 'd1e_MAGE',
),
'mtime' => '1668695167',
)
metadatas result from backend: false
I think the Magento wrapper uppercases the keys so when you bypass the Magento wrapper you have to uppercase the keys yourself.
Hello
I have been trying to debug something using
getMetadata
but no matter what I do it seems to always returnfalse
.Can you see that I am doing anything wrong here?
Test script
Output