Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用;警告:Memcached::setOption()要求参数1为整数,字符串为;使用Redis Memcached from";“Redis企业云”;与Symfony 5_Redis_Memcached_Php 7_Symfony5 - Fatal编程技术网

&引用;警告:Memcached::setOption()要求参数1为整数,字符串为;使用Redis Memcached from";“Redis企业云”;与Symfony 5

&引用;警告:Memcached::setOption()要求参数1为整数,字符串为;使用Redis Memcached from";“Redis企业云”;与Symfony 5,redis,memcached,php-7,symfony5,Redis,Memcached,Php 7,Symfony5,以下是Symfony项目的my 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_expi

以下是Symfony项目的my 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));    }    /**

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));    }

如果我取消对以下行的注释

- [setSaslAuthData, ['%session_memcached_user%','%session_memcached_pass%']]
然后它给出以下警告,因为它不支持没有二进制文件的SASL

Warning: Memcached::setSaslAuthData(): SASL is only supported with binary protocol

获取以下错误异常

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

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));    }


我不明白为什么Symfony只在将第一个参数“Memcached::OPT_BINARY_PROTOCOL”添加到services.yaml中时才将其视为字符串

我通过启用default memcached.default\u binary\u协议解决了这个问题

我在/etc/php/7.2/mods-available/memcached.ini中添加了这一行

memcached.default_binary_protocol = On

下面是我对Symfony项目的services.yaml文件的最终配置

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:
           - [setSaslAuthData, ['%session_memcached_user%','%session_memcached_$
           - [addServer, ['%session_memcached_host%','%session_memcached_port%'$

    session.handler.memcached:
        class: Symfony\Component\HttpFoundation\Session\Storage\Handler\Memcach$
        arguments: ["@session.memcached", { prefix: '%session_memcached_prefix%$

现在它正在Redislabs Memcached上存储会话:)