コード例 #1
0
ファイル: Filesystem.php プロジェクト: fwk/cache
 /**
  *
  * @param string $fileName
  * 
  * @return CacheEntry 
  */
 public function readEntry($key)
 {
     if (!$this->exists($key)) {
         return false;
     }
     $fileInfos = implode(DIRECTORY_SEPARATOR, array($this->cacheDirectory, md5('cacheKey:' . $key) . '.cache'));
     $contents = file_get_contents($fileInfos);
     $entry = $this->serializer->unserialize($contents);
     if (!$entry instanceof \Fwk\Cache\CacheEntry) {
         throw new \Fwk\Cache\Exceptions\ReadError("contents is not a valid CacheEntry");
     }
     $entry->setSerializer($this->serializer);
     return $entry;
 }
コード例 #2
0
ファイル: Database.php プロジェクト: fwk/cache
 /**
  *
  * @param string $fileName
  * 
  * @return CacheEntry 
  */
 public function readEntry($key)
 {
     $query = "SELECT * FROM %s WHERE `key` = ? LIMIT 1";
     $stmt = $this->pdo->prepare(sprintf($query, $this->options['table.infos']));
     $stmt->execute(array($key));
     $res = $stmt->fetch();
     if (!$res) {
         throw new \Fwk\Cache\Exceptions\ReadError("invalid CacheEntry key: {$key}");
     }
     $entry = new \Fwk\Cache\CacheEntry(null, $key);
     $entry->setCreatedOn($res['created_on']);
     $entry->setKey($res['key']);
     if (strlen($res['max_age']) > 50) {
         $maxAge = $this->serializer->unserialize($res['max_age']);
     } else {
         $maxAge = $res['max_age'];
     }
     $entry->setMaxAge($maxAge);
     $entry->setSerializer($this->serializer);
     return $entry;
 }
コード例 #3
0
 /**
  * @param  resource|string $stream
  * @param  mixed           $object
  * @param  string          $format
  * @return mixed
  */
 public function unserialize($stream, &$object = null, $format = null)
 {
     return $this->serializer->unserialize($stream, $format ?: $this->format, $this->type, $this->options, $object);
 }
コード例 #4
0
ファイル: SerializerTest.php プロジェクト: link0/profiler
 /**
  * @expectedException \Link0\Profiler\SerializerException
  * @expectedExceptionMessage Unable to unserialize data: FDSAfoobar
  */
 public function testUnexpectedDataToThrowException()
 {
     $this->serializer->unserialize('FDSAfoobar');
 }
コード例 #5
0
ファイル: ArraySerializable.php プロジェクト: cawaphp/cawa
 /**
  * @param array $serialized
  */
 public function arrayUnserialize(array $serialized)
 {
     Serializer::unserialize($this, $serialized);
 }
コード例 #6
0
ファイル: JsonSerializable.php プロジェクト: cawaphp/cawa
 /**
  * @param string $serialized
  */
 public function jsonUnserialize(string $serialized)
 {
     Serializer::unserialize($this, json_decode($serialized, true));
 }
コード例 #7
0
ファイル: Serializable.php プロジェクト: cawaphp/cawa
 /**
  * @param string $serialized
  */
 public function unserialize($serialized)
 {
     Serializer::unserialize($this, unserialize($serialized));
 }
コード例 #8
0
 protected function getVideoDetails()
 {
     $unserialized = Serializer::unserialize($this->video->getFeed());
     return XMLLoader::loadString($unserialized);
 }