Пример #1
0
 /**
  * Updates the cache.
  */
 public function save()
 {
     foreach ($this->_update as $mbox => $val) {
         try {
             if (!empty($val['u'])) {
                 $ptr =& $this->_data[$mbox];
                 foreach ($this->_getMsgCids($mbox, array_keys($val['u'])) as $k2 => $v2) {
                     try {
                         $this->_hash->set($v2, $this->_pack->pack($ptr[$k2]), array('expire' => $this->_params['lifetime']));
                     } catch (Horde_Pack_Exception $e) {
                         $this->deleteMsgs($mbox, array($v2));
                         $val['d'][] = $v2;
                     }
                 }
             }
             if (!empty($val['d'])) {
                 $this->_hash->delete(array_values($this->_getMsgCids($mbox, $val['d'])));
             }
             if (!empty($val['m'])) {
                 try {
                     $this->_hash->set($this->_getCid($mbox), $this->_pack->pack($this->_mbox[$mbox]), array('expire' => $this->_params['lifetime']));
                 } catch (Horde_Pack_Exception $e) {
                 }
             }
         } catch (Horde_Exception $e) {
         }
     }
     $this->_update = array();
 }
Пример #2
0
 /**
  * Do garbage collection for session tracking information.
  */
 public function trackGC()
 {
     $this->_hash->lock($this->_trackID);
     if ($ids = $this->_getTrackIds()) {
         $alter = false;
         foreach (array_keys($ids) as $key) {
             if (!$this->_hash->exists($key)) {
                 unset($ids[$key]);
                 $alter = true;
             }
         }
         if ($alter) {
             $this->_hash->set($this->_trackID, json_encode($ids));
         }
     }
     $this->_hash->unlock($this->_trackID);
 }
Пример #3
0
 /**
  */
 public function set($key, $data, $lifetime = 0)
 {
     $opts = array_filter(array('expire' => $lifetime));
     $this->_hash->set($this->_getKey($key), $data, $opts);
     $this->_hash->set($this->_getKey($key, true), time(), $opts);
 }