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

Set the value of a key.
См. также: Memcache::set()
public set ( string $key, string $var, $expire ) : boolean
$key string The key.
$var string The data to store.
Результат boolean True on success.
Пример #1
0
 /**
  */
 public function set($key, $data, $lifetime = 0)
 {
     $key = $this->_params['prefix'] . $key;
     if ($this->_memcache->set($key . '_e', time(), $lifetime) !== false) {
         $this->_memcache->set($key, $data, $lifetime);
     }
 }
Пример #2
0
 /**
  * Do garbage collection for session tracking information.
  */
 public function trackGC()
 {
     $this->_memcache->lock($this->_trackID);
     $ids = $this->_memcache->get($this->_trackID);
     if (empty($ids)) {
         $this->_memcache->unlock($this->_trackID);
         return;
     }
     $tstamp = time() - $this->_params['track_lifetime'];
     $alter = false;
     foreach ($ids as $key => $val) {
         if ($tstamp > $val) {
             unset($ids[$key]);
             $alter = true;
         }
     }
     if ($alter) {
         $this->_memcache->set($this->_trackID, $ids);
     }
     $this->_memcache->unlock($this->_trackID);
 }
Пример #3
0
 /**
  */
 protected function _set($key, $val, $opts)
 {
     return empty($opts['replace']) ? $this->_memcache->set($key, $val, isset($opts['expire']) ? $opts['expire'] : 0) : $this->_memcache->replace($key, $val, isset($opts['expire']) ? $opts['expire'] : 0);
 }