/**
  * @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());
         });
     }
 }