如何使用 FOSUSERBUNDLE 和 MEMCACHED?

how to use FOSUSERBUNDLE and MEMCACHED?

我像那样注入了 services.yml

services:
    memcache:
        class: Memcache
        calls:
            - [ addServer, [ %session_memcached_host%, %session_memcached_port% ]]  
    session.handler.memcache:
            class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler
            arguments: [@memcache]

和我的 config.yml

handler_id: session.handler.memcache

和我的 php.ini

    extension="memcache.so"
    session.save_handler= memcache

    session.save_path= tcp://127.0.0.1:11211

我使用这个 link 安装了 memcached 但是当我加载 fosbundle 登录页面时出现这个错误

Attempted to load class "Memcache" from the global namespace.
Did you forget a "use" statement?

将 symfony 与 memcached 集成的一种简单方法是使用现有的捆绑包。我使用 leaseweb/memcache-bundle,它非常简单 - 只需按照此处的说明操作即可:https://github.com/LeaseWeb/LswMemcacheBundle。记得先启动 memcached ;)

尚未将其与 FOSUserBundle 完全集成,但它确实支持 php 个会话。