Esempio n. 1
0
 /**
  *
  * @param string $fileName
  * @param string $contents 
  * 
  * @return int
  */
 public function write(\Fwk\Cache\CacheEntry $entry)
 {
     if ($this->exists($entry->getKey())) {
         $this->delete($entry->getKey());
     }
     $maxAge = $entry->getMaxAge();
     if (is_object($maxAge)) {
         $maxAge = $this->serializer->serialize($maxAge);
     }
     $query = "INSERT INTO %s VALUES (%s,%s,%s,%s)";
     $stmt = $this->pdo->exec(sprintf($query, $this->options['table.infos'], $this->pdo->quote($entry->getKey()), $this->pdo->quote($entry->getCreatedOn()), $this->pdo->quote($maxAge), $this->pdo->quote(implode(self::TAGS_SEPARATOR, $entry->getTags()))));
     $entry->setSerializer($this->serializer);
     $query = "INSERT INTO %s VALUES (%s, %s)";
     $stmt = $this->pdo->exec(sprintf($query, $this->options['table.entries'], $this->pdo->quote($entry->getKey()), $this->pdo->quote($entry->getSerializedContents())));
     return true;
 }