【问题标题】:Clear Doctrine cache stored in Redis清除存储在 Redis 中的 Doctrine 缓存
【发布时间】:2014-11-13 08:52:25
【问题描述】:

我开始在我的项目 (php-redis) 上使用 Redis。是一个 Symfony2 项目,我发现了:

https://github.com/snc/SncRedisBundle

我按照安装过程进行配置:

  • 一些客户端存储no-sql数据和缓存
  • 会话存储
  • Doctrine 元数据、结果和查询缓存

我在捆绑包中创建了一个新实体,但失败了,因为我在 yml 中创建了它,而我拥有所有其他带有注释系统的实体,所以我删除了 yml 格式并创建了注释。

我对注释类所做的每项更改(例如更改表名)都不会影响架构或数据库,即使我重新创建数据库或尝试使用所有选项执行缓存:清除。

如果我只是评论 redis 教义配置行,它可以工作,我可以看到架构上的更改。

我可能忘记了什么,或者我真的找不到如何清理那个学说 redis 缓存。

¿我必须手动清理 redis 客户端上用于缓存的任何位置?

这里是配置:

#Snc Redis Bundle
snc_redis:
  clients:
    d2a:
        type: phpredis
        alias: d2a
        dsn: redis://localhost/1
    cache:
        type: phpredis
        alias: cache
        dsn: redis://localhost
        logging: true
  session:
    client: d2a
    prefix: redis_session
  doctrine:
    metadata_cache:
        client: cache
        entity_manager: default          # the name of your entity_manager connection
        document_manager: default        # the name of your document_manager connection
    result_cache:
        client: cache
        entity_manager: [default, read]  # you may specify multiple entity_managers
    query_cache:
        client: cache
        entity_manager: default

【问题讨论】:

  • 您是否尝试过完全删除实体并使用注释而不是 yml 重新创建它?
  • 是的,我试过了,是在解释我的问题

标签: php symfony caching doctrine-orm redis


【解决方案1】:

最简单但不是最好的方法是使用学说缓存刷新 redis db。运行

php app/console redis:flushdb --client=cache

(未测试!)另一种方法是在教义配置http://symfony.com/doc/current/reference/configuration/doctrine.html#caching-drivers中设置教义元数据缓存

orm:
    entity_managers:
        # A collection of different named entity managers (e.g. some_em, another_em)
        some_em:
            metadata_cache_driver:
                type:                 array # Required
                host:                 ~
                port:                 ~
                instance_class:       ~
                class:                ~

【讨论】:

    猜你喜欢
    • 2018-05-26
    • 2016-09-10
    • 2013-03-11
    • 1970-01-01
    • 2015-04-16
    • 2015-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多