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

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

public add ( string $key, mixed $value, integer $expire )
$key string
$value mixed
$expire integer
    public function add($key, $value, $expire)
    {
        $args = array('key' => $key, 'value' => $value, 'expire' => $expire);
        $this->keys[$key] = array(__FUNCTION__, array($this->cache, __FUNCTION__), $args);
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 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;
 }