清除存储在Redis中的教义缓存

ruu*_*udy 5 php caching redis symfony doctrine-orm

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

https://github.com/snc/SncRedisBundle

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

  • 一些客户端存储no-sql数据并缓存
  • 会话存储
  • 学说元数据,结果和查询缓存

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

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

如果我只评论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
Run Code Online (Sandbox Code Playgroud)

Jek*_*kis 3

最简单但不是最好的方法是使用原则缓存刷新 Redis 数据库。跑步

php app/console redis:flushdb --client=cache
Run Code Online (Sandbox Code Playgroud)

(未经测试!)另一种方法是在学说配置中设置学说元数据缓存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:                ~
Run Code Online (Sandbox Code Playgroud)