feat: 同步下新环境

This commit is contained in:
笔记本里的永平
2025-07-07 11:31:25 +08:00
parent 3d1050db3d
commit 86c261ba70
196 changed files with 13146 additions and 29319 deletions

View File

@@ -11,10 +11,10 @@
namespace think\session\driver;
use SessionHandlerInterface;
use SessionHandler;
use think\Exception;
class Memcache implements SessionHandlerInterface
class Memcache extends SessionHandler
{
protected $handler = null;
protected $config = [
@@ -34,8 +34,8 @@ class Memcache implements SessionHandlerInterface
/**
* 打开Session
* @access public
* @param string $savePath
* @param mixed $sessName
* @param string $savePath
* @param mixed $sessName
*/
public function open($savePath, $sessName)
{
@@ -43,17 +43,13 @@ class Memcache implements SessionHandlerInterface
if (!extension_loaded('memcache')) {
throw new Exception('not support:memcache');
}
$this->handler = new \Memcache;
// 支持集群
$hosts = explode(',', $this->config['host']);
$ports = explode(',', $this->config['port']);
if (empty($ports[0])) {
$ports[0] = 11211;
}
// 建立连接
foreach ((array) $hosts as $i => $host) {
$port = isset($ports[$i]) ? $ports[$i] : $ports[0];
@@ -61,7 +57,6 @@ class Memcache implements SessionHandlerInterface
$this->handler->addServer($host, $port, $this->config['persistent'], 1, $this->config['timeout']) :
$this->handler->addServer($host, $port, $this->config['persistent'], 1);
}
return true;
}
@@ -74,14 +69,13 @@ class Memcache implements SessionHandlerInterface
$this->gc(ini_get('session.gc_maxlifetime'));
$this->handler->close();
$this->handler = null;
return true;
}
/**
* 读取Session
* @access public
* @param string $sessID
* @param string $sessID
*/
public function read($sessID)
{
@@ -91,8 +85,8 @@ class Memcache implements SessionHandlerInterface
/**
* 写入Session
* @access public
* @param string $sessID
* @param string $sessData
* @param string $sessID
* @param String $sessData
* @return bool
*/
public function write($sessID, $sessData)
@@ -103,7 +97,7 @@ class Memcache implements SessionHandlerInterface
/**
* 删除Session
* @access public
* @param string $sessID
* @param string $sessID
* @return bool
*/
public function destroy($sessID)
@@ -114,7 +108,7 @@ class Memcache implements SessionHandlerInterface
/**
* Session 垃圾回收
* @access public
* @param string $sessMaxLifeTime
* @param string $sessMaxLifeTime
* @return true
*/
public function gc($sessMaxLifeTime)