symfony2使用Memcached存储Session

1、添加如下代码到app/config/services.yml:

parameters:
    memcached.servers:
      - { host: 127.0.0.1, port: 11211 }  

services:
    session.handler.memcached:
        class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
        arguments:
            - "@memcached"
            -  { prefix : "im_" }
    memcached:
        class: Memcached
        calls:
            - [ addServers, [ %memcached.servers% ]]

2、修改app/config/config.yml文件中的handler_id为上面定义的service id

framework:
    session:
        handler_id: session.handler.memcached


你可能感兴趣的:(symfony2)