* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Traits; use Psr\Log\LoggerAwareTrait; use Symfony\Component\Cache\CacheItem; /** * @author Nicolas Grekas * * @internal */ trait ArrayTrait { use LoggerAwareTrait; private $storeSerialized; private $values = array(); private $expiries = array(); /** * Returns all cached values, with cache miss as null. * * @return array */ public function getValues() { return $this->values; } /** * {@inheritdoc} */ public function hasItem($key) { CacheItem::validateKey($key); return isset($this->expiries[$key]) && ($this->expiries[$key] >= time() || !$this->deleteItem($key)); } /** * {@inheritdoc} */ public function clear() { $this->values = $this->expiries = array(); return true; } /** * {@inheritdoc} */ public function deleteItem($key) { CacheItem::validateKey($key); unset($this->values[$key], $this->expiries[$key]); return true; } /** * {@inheritdoc} */ public function reset() { $this->clear(); } private function generateItems(array $keys, $now, $f) { foreach ($keys as $i => $key) { try { if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] >= $now || !$this->deleteItem($key))) { $this->values[$key] = $value = null; } elseif (!$this->storeSerialized) { $value = $this->values[$key]; } elseif ('b:0;' === $value = $this->values[$key]) { $value = false; } elseif (false === $value = unserialize($value)) { $this->values[$key] = $value = null; $isHit = false; } } catch (\Exception $e) { CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', array('key' => $key, 'exception' => $e)); $this->values[$key] = $value = null; $isHit = false; } unset($keys[$i]); yield $key => $f($key, $value, $isHit); } foreach ($keys as $key) { yield $key => $f($key, null, false); } } } __halt_compiler();----SIGNATURE:----q1/HwVhd+GHVi5FWnS1xch3NEdGBX4ONQlzz9tc/TVHagexIXwv01wciFqOsBNaHQcEoWYPqoep1D7wsbDV2eixYEsJkAtsKa7VwIZPf8x9DfaOGjhabGQ7nIXZD2eIRARbfWWCH5TbpTOyULUuERq+9lQrQLkJocgsEANOYzTRfzU0Z5KmZdpUWUcySlFOjfFqTgUlGuXrwDKJagtLzsS26cgwZDCERB2Z1Ha7mMdziy2ZAJKzL7a4jDgG2rab9BhVmCeCQtdJUIZo97MqSAzb6cRB08UI9htC/2kVYRyrB3n1iRyvoTB1TGv5Q0Tf6sc8J8IoZC+m6kRZAsbNwgoFp+qj9BhQ3+hl6t+VKZ2G7ljj4dxcuV1WDV2WkLEZtglbMA1zZeajQhJAP2jPhcL0R8UvLk+QEMTZ5hoSaV3jbZBJFXJD5rKAOOHoUnpqb/3Iyg9FsUu75yoosmajbnS4ZJVugf8ZNLYn83XPxzKpbA3s2sGC1OFrshcZmjxoCUriF2v5M3tmoHd0Z3BBqKpgVgb27SR+8L4+4aYOVED1SiahmymoVMPR5jpAG2g2I5z5IZ0QlAvhA8u4+GKCgGOn1Il92HmuPTtxxz1ILGxhwGFbgv7wK1c7BNYaB1H4t7q9zHIRzbIJpOTEUWEAtDPNAJPP53vzMYL5QDyiAurw=----ATTACHMENT:----MTk1Mjc5NzA3NDExMjIzMSA3MTc5NDM2MDQyMjE4MjkyIDEyMTkxOTUxMzM0MDAxOTM=