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

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

public touch ( string $key, integer $expire )
$key string
$expire integer
    public function touch($key, $expire)
    {
        if (isset($this->keys[$key]) && isset($this->keys[$key][2]['expire'])) {
            // changing expiration time of a value we're already storing in
            // this transaction - might as well just set new expiration time
            // right away
            $this->keys[$key][2]['expire'] = $expire;
        } else {
            $args = array('key' => $key, 'expire' => $expire);
            $this->keys[$key] = array(__FUNCTION__, array($this->cache, __FUNCTION__), $args);
        }
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function touch($key, $expire)
 {
     // grab existing value (from real cache or memory) and re-save (to
     // memory) with updated expiration time
     $value = $this->get($key);
     if ($value === false) {
         return false;
     }
     $success = $this->local->set($key, $value, $expire);
     if ($success === false) {
         return false;
     }
     $this->defer->touch($key, $expire);
     return true;
 }