php – 存储在Redis中的Clear Doctrine缓存

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 存储在Redis中的Clear Doctrine缓存脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
开始在我的项目上使用redis(PHP-redis).是一个Symfony2项目,我发现:

https://github.com/snc/SncRedisBundle

我按照安装过程配置:

>一些客户端存储no-sql数据和缓存
>会话存储
> Doctrine Metada,结果和查询缓存

我在一个包中创建了一个新实体,但是我失败了,因为我在yML创建了它,并且我有其他所有注释系统,所以我删除了yml格式并创建了注释.

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

如果我只是评论redis 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

解决方法

简单方法,但不是最好的方法是使用doctrine缓存刷新redis数据库.跑

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

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

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

脚本宝典总结

以上是脚本宝典为你收集整理的php – 存储在Redis中的Clear Doctrine缓存全部内容,希望文章能够帮你解决php – 存储在Redis中的Clear Doctrine缓存所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。