get() public method

Get data associated with a key.
See also: Memcache::get()
public get ( mixed $keys ) : mixed
$keys mixed The key or an array of keys.
return mixed The string/array on success (return type is the type of $keys), false on failure.
示例#1
0
 /**
  */
 public function get($key, $lifetime = 0)
 {
     $original_key = $key;
     $key = $this->_params['prefix'] . $key;
     if (isset($this->_expirecache[$key])) {
         return $this->_expirecache[$key];
     }
     $key_list = array($key);
     if (!empty($lifetime)) {
         $key_list[] = $key . '_e';
     }
     $res = $this->_memcache->get($key_list);
     if ($res === false) {
         unset($this->_expirecache[$key]);
     } else {
         // If we can't find the expire time, assume we have exceeded it.
         if (empty($lifetime) || $res[$key . '_e'] !== false && $res[$key . '_e'] + $lifetime > time()) {
             $this->_expirecache[$key] = $res[$key];
         } else {
             $res[$key] = false;
             $this->expire($original_key);
         }
     }
     return $res[$key];
 }
示例#2
0
文件: Memcache.php 项目: horde/horde
 /**
  * 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
文件: Memcache.php 项目: horde/horde
 /**
  */
 protected function _get($keys)
 {
     return ($res = $this->_memcache->get($keys)) === false ? array_fill_keys($keys, false) : $res;
 }