コード例 #1
0
 /**
  * @param Session $session
  */
 public function save(Session $session)
 {
     $sid = $session->getSid();
     $redisId = $this->buildKey($sid);
     if ($session->shouldKill()) {
         $this->redis->del($redisId);
     } else {
         $this->redis->transaction(function (MultiExec $tx) use($session, $redisId) {
             foreach ($session->getDeletedKeys() as $key) {
                 $tx->hdel($redisId, $key);
             }
             $changes = $session->getChanges();
             if (count($changes) > 0) {
                 $tx->hmset($redisId, $session->getChanges());
             }
             // session regeneration is not supported
             $tx->expire($redisId, $this->getExpires());
         });
         $this->oracleKeepAlive($sid);
     }
 }
コード例 #2
0
 /**
  * @param Session $session
  */
 public function save(Session $session)
 {
     $redisId = $this->buildKey($session->getSid());
     if ($session->shouldKill()) {
         $this->redis->del($redisId);
     } else {
         $this->redis->transaction(function (MultiExec $tx) use($session, $redisId) {
             foreach ($session->getDeletedKeys() as $key) {
                 $tx->hdel($redisId, $key);
             }
             $changes = $session->getChanges();
             if (count($changes) > 0) {
                 $tx->hmset($redisId, $session->getChanges());
             }
             if ($session->shouldRegenerate()) {
                 $session->setSid(UUID::v4());
                 $newRedisId = $this->buildKey($session->getSid());
                 $tx->rename($redisId, $newRedisId);
                 $redisId = $newRedisId;
             }
             $tx->expire($redisId, $this->getExpires());
         });
     }
 }