清除存储在Redis中的Doctrine缓存



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

https://github.com/snc/SncRedisBundle

我遵循安装过程并配置:

  • 一些客户端不存储sql数据和缓存
  • 会话存储
  • 条令元数据、结果和查询缓存

我在一个bundle中创建了一个新的实体,但我失败了,因为我在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

最简单但不是最好的方法是用条令缓存刷新redis-db。运行

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

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

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:                ~

最新更新