将 Memcached 服务添加到 symfony2

Add Memcahed service to symfony2

服务:

memcached:
    class: Memcached
    calls:
      -[addServers,[%memcached.servers%]]

参数:

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

当我尝试此代码时出现错误

Parameter "calls" must be an array for service "memcached" in
 ...Resources/config/services.yml. Check your YAML syntax 

我尝试连线,但错误是一样的。

您的 YAML 无效。应该是:

  - [addServers,[%memcached.servers%]]

在块的末尾

这是我的配置:

config.yml

memcached:
    class: Memcached
    calls:
        - [ addServer, ['%memcached.host%', '%memcached.port%'] ]

在我的 config.yml 中,减号 under 是关于 s 而不是你的 l 的调用(另请参见 in the doc)。

希望对您有所帮助