コード例 #1
0
ファイル: Db.php プロジェクト: nkammah/Crash-Analytics
 /**
  * (non-PHPdoc)
  * @see \Koldy\Cache\Driver\AbstractCacheDriver::set()
  */
 public function set($key, $value, $seconds = null)
 {
     $this->checkKey($key);
     if ($seconds === null) {
         $seconds = $this->defaultDuration;
     }
     $update = new Update($this->config['table']);
     $update->setConnection($this->config['connection']);
     $ok = $update->set('updated_at', date('Y-m-d H:i:s'))->set('expires_at', time() + $seconds)->set('data', serialize($value))->where('id', $key)->exec();
     if ($ok === false || $ok === 0 && !$this->has($key)) {
         $insert = new Insert($this->config['table']);
         $insert->setConnection($this->config['connection']);
         $insert->add(array('id' => $key, 'updated_at' => date('Y-m-d H:i:s'), 'expires_at' => time() + $seconds, 'data' => serialize($value)));
         $insert->exec();
     }
     return true;
 }