【问题标题】:Symfony 3.1 PSR-6 Caching SettingsSymfony 3.1 PSR-6 缓存设置
【发布时间】:2016-08-15 08:56:45
【问题描述】:

Config.yml:

cache:
    app: cache.adapter.doctrine
    system: cache.adapter.doctrine
    default_doctrine_provider: ~
    default_psr6_provider: ~
    default_redis_provider: "redis://localhost:6379"

Symfony 3.1 支持学说缓存,但您没有足够的文档。

缓存组件:http://symfony.com/doc/current/components/cache.html
支持的驱动器:http://symfony.com/doc/current/components/cache/cache_pools.html
Symfony 集成:http://symfony.com/blog/new-in-symfony-3-1-cache-component

default_doctrine_provider: ?作为提供者我应该输入什么

【问题讨论】:

    标签: php caching doctrine-orm symfony symfony-3.1


    【解决方案1】:

    您可以将 Redis 连接 DSN(例如“redis://127.0.0.1:6379”)或实现 Symfony\Component\Cache\Adapter\AdapterInterface 的服务的 ID 传递给 default_doctrine_provider

    你可以看看已经实现的适配器here

    【讨论】:

      【解决方案2】:

      提供程序基本上是您配置的原始doctrine_cache 提供程序。假设您使用DoctrineCacheBundle 并且您的提供者名称是my_apc_cache,这意味着容器具有以下服务:

      $myCache = $this->container->get('doctrine_cache.providers.my_apc_cache');
      

      你也可以定义一个别名,那就更简单了。

      看看这个例子:https://symfony.com/doc/current/bundles/DoctrineCacheBundle/usage.html#service-aliases

      【讨论】:

        猜你喜欢
        • 2018-07-13
        • 1970-01-01
        • 2018-10-25
        • 1970-01-01
        • 2020-03-30
        • 2016-10-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多