summaryrefslogtreecommitdiffstats
path: root/system/libraries/Session/drivers
diff options
context:
space:
mode:
authortianhe1986 <w1s2j3229@163.com>2017-07-05 10:54:01 +0200
committertianhe1986 <w1s2j3229@163.com>2017-07-05 10:54:01 +0200
commit569cf69078de1c8a970ab4259467dfe27b4cdb96 (patch)
treeb84d4a268f6f6d62ed2913e43df2270bb2d1ca56 /system/libraries/Session/drivers
parent5b5e053b95a586c3c278e8d7c9d55c2459ed0908 (diff)
Acquiring redis lock with existence check.
Signed-off-by: tianhe1986 <w1s2j3229@163.com>
Diffstat (limited to 'system/libraries/Session/drivers')
-rw-r--r--system/libraries/Session/drivers/Session_redis_driver.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php
index 2aeb77267..8fc0a45da 100644
--- a/system/libraries/Session/drivers/Session_redis_driver.php
+++ b/system/libraries/Session/drivers/Session_redis_driver.php
@@ -365,7 +365,16 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
continue;
}
- if ( ! $this->_redis->setex($lock_key, 300, time()))
+ if ($ttl === -2)
+ {
+ $set_result = $this->_redis->set($lock_key, time(), array('nx', 'ex' => 300));
+ }
+ else
+ {
+ $set_result = $this->_redis->setex($lock_key, 300, time());
+ }
+
+ if ( ! $set_result)
{
log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id);
return FALSE;