MatthiasMullie\Scrapbook\Buffered\Utils\Transaction::add PHP Метод

add() публичный Метод

public add ( $key, $value, $expire )
    public function add($key, $value, $expire = 0)
    {
        // before adding, make sure the value doesn't yet exist (in real cache,
        // nor in memory)
        if ($this->get($key) !== false) {
            return false;
        }
        // store the value in memory, so that when we ask for it again later
        // in this same request, we get the value we just set
        $success = $this->local->set($key, $value, $expire);
        if ($success === false) {
            return false;
        }
        $this->defer->add($key, $value, $expire);
        return true;
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function add($key, $value, $expire = 0)
 {
     $result = $this->transaction->add($key, $value, $expire);
     $this->transaction->commit();
     return $result;
 }