以下是我的 Symfony 项目 services.yaml 的配置,[我正在尝试在 Redis Enterprise Cloud Memcached 上存储会话]
parameters:
session_memcached_host: memcached-11999.someurl.redislabs.com
session_memcached_port: 11999
session_memcached_prefix: test
session_memcached_expire: 3600 # this is in seconds
session_memcached_user: abcd
session_memcached_pass: abcd
services:
session.memcached:
class: Memcached
arguments:
calls:
- [addServer, ['%session_memcached_host%','%session_memcached_port%']]
# - [setSaslAuthData, ['%session_memcached_user%','%session_memcached_pass%']]
- [setOption, [Memcached::OPT_BINARY_PROTOCOL, true]]
session.handler.memcached:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
arguments: ["@session.memcached", { prefix: '%session_memcached_prefix%', expiretime: '%session_memcached_expire%' }]
获取以下错误异常
in var/cache/dev/ContainerIG8bgiG/App_KernelDevDebugContainer.php (line 1635)
include_once \dirname(__DIR__, 4).'/vendor/symfony/http-foundation/Session/SessionBagInterface.php';
include_once \dirname(__DIR__, 4).'/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php';
$a = new \Memcached();
$a->addServer('memcached-11999.someurl.redislabs.com', 11999);
$a->setOption('Memcached::OPT_BINARY_PROTOCOL', true);
return $this->privates['session.storage.native'] = new\Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage($this->parameters['session.storage.options'], new \Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler($a, ['prefix' => 'test', 'expiretime' => 3600]), new \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag('_sf2_meta', 0)); } /**
如果我取消注释以下行
- [setSaslAuthData, ['%session_memcached_user%','%session_memcached_pass%']]
然后它给出以下警告,因为它不支持没有二进制文件的 SASL
Warning: Memcached::setSaslAuthData(): SASL is only supported with binary protocol
获取以下错误异常
in var/cache/dev/ContainerNVvLqte/App_KernelDevDebugContainer.php (line 1635)
include_once \dirname(__DIR__, 4).'/vendor/symfony/http-foundation/Session/SessionBagInterface.php';
include_once \dirname(__DIR__, 4).'/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php';
$a = new \Memcached();
$a->addServer('memcached-11999.someurl.redislabs.com', 11999);
$a->setSaslAuthData('abcd', 'abcd');
$a->setOption('Memcached::OPT_BINARY_PROTOCOL', true);
return $this->privates['session.storage.native'] = new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage($this->parameters['session.storage.options'], new \Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler($a, ['prefix' => 'test', 'expiretime' => 3600]),
new \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag('_sf2_meta', 0)); }