加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 22:53:35 所属栏目:PHP教程 来源:网络整理
导读:我开始在我的项目上使用Redis(php-redis).是一个Symfony2项目,我发现: https://github.com/snc/SncRedisBundle 我按照安装过程配置: 一些客户端存储no-sql数据和缓存 会话存储 Doctrine metada,结果和查询缓存 我在一个包中创建了一个新实体,但是我失败了,
我开始在我的项目上使用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:                ~

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读