public function testEncodeDecode()
 {
     $length = rand(0, 100);
     $value = [];
     for ($i = 0; $i < $length; $i++) {
         if (rand(0, 1)) {
             $value[] = Str::random();
         } else {
             $value[count($value) - 1] = Str::random();
         }
     }
     $ttl = rand(0, 100000000);
     $tags = ['Tag1', 'Tag2'];
     $now = time();
     $encoded = (string) CacheItem::encode($value, $ttl, $tags, $now);
     $decoded = CacheItem::decode($encoded);
     $this->assertEquals($value, $decoded->getValue());
     $this->assertEquals($ttl + $now, $decoded->getExpires());
     $this->assertEquals($tags, $decoded->getTags());
 }
 public function deserialize($prefix, array $data)
 {
     $data = ArrayTools::stripPrefixFromArrayKeys($prefix, $data);
     $data = array_map(function ($cacheItem) {
         return CacheItem::decode($cacheItem);
     }, $data);
     /** @var CacheItem[] $data */
     foreach ($data as &$item) {
         if ($item->isExpired()) {
             $item = null;
             continue;
         }
         if ($this->tagVersions->isAnyTagExpired($item->getTags())) {
             $item = null;
             continue;
         }
         $value = $item->getValue();
         $item = $this->isSimpleType($value) ? $value : $this->coderManager->decode($value);
     }
     return $data;
 }