清除Redis中存储的Doctrine缓存

6
我开始在我的Symfony2项目(php-redis)中使用Redis。我发现了https://github.com/snc/SncRedisBundle,并按照安装过程进行配置:
- 配置一些客户端用于存储NoSQL数据和缓存 - 会话存储 - Doctrine元数据、结果和查询缓存
我在一个bundle中创建了一个新的实体,但由于我使用了yml格式,而其他所有实体都是注释系统,所以我删除了yml格式并创建了注释格式。
每当我更改注释类(例如更改表名)时,它不会影响模式或数据库,即使我重新创建数据库或尝试使用所有选项执行cache:clear。
如果我只是注释掉redis doctrine配置行,它就可以正常工作,并且我可以看到模式的变化。
我可能忘记了什么,或者我真的找不到如何清除Doctrine 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吗? - andy
是的,我尝试过了,这是关于我的问题的解释。 - ruudy
1个回答

3

最简单但不是最好的方法是使用Doctrine缓存来刷新Redis数据库。运行:

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

(未经测试!)另一种方法是在Doctrine配置中设置Doctrine元数据缓存。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:                ~

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接