Exemplo n.º 1
0
 /**
  * Garbage collector (do nothing as redis takes care about deletion of expired keys)
  *
  * @param int $max_lifetime session lifetime
  *
  * @return boolean always true
  */
 public function gc($max_lifetime)
 {
     // Move expired sessions to sessions storage
     $session_ids = array_map(function ($key) {
         return substr($key, strrpos($key, ':') + 1);
     }, $this->query('keys', $this->id('*')));
     if (!empty($session_ids)) {
         foreach ($session_ids as $sess_id) {
             $session = $this->query('hGetAll', $this->id($sess_id));
             if (empty($session) || $session['expiry'] < TIME) {
                 if (!empty($session['data'])) {
                     Session::expire($sess_id, $session);
                 }
                 $this->delete($sess_id);
             }
         }
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Garbage collector - move expired sessions to session archive
  *
  * @param int $max_lifetime session lifetime
  *
  * @return boolean always true
  */
 public function gc($max_lifetime)
 {
     $sessions = db_get_array('SELECT * FROM ?:sessions WHERE expiry < ?i', TIME);
     if ($sessions) {
         foreach ($sessions as $session) {
             Session::expire($session['session_id'], $session);
         }
         // delete old sessions
         db_query('DELETE FROM ?:sessions WHERE expiry < ?i', TIME);
     }
     return true;
 }