<?php
use Symfony\Component\Cache\Adapter\ArrayAdapter;
$cache = new ArrayAdapter();
$itemKey = 'cacheMeIfYouCan';
$value = 'Foo';
if (false === $cache->hasItem($itemKey)) {
echo 'Write value in cache' . PHP_EOL;
$item = $cache->getItem($itemKey);
$item->set($value);
$cache->save($item);
}
$item = $cache->getItem($itemKey);
dump($item->get());
^ "Foo"