Clear doctrine cache in redis on deploy

We keep our doctrine cache in redis, and use capistrano for deployment. Everything works nice until we have to remove a field on entity.

When post install commands in composer are executed we get error like:

[ReflectionException] ** [out Property EntitiesPlayerRecord::$shirtNumber does not exist

$shirtNumber is the field that we removed. To be able to continue we just need to clear doctrine cache but because it is in redis database, the cache is shared with production.

The question is how can we dynamically change connection setting for redis on each deploy? The only ideas that come to my mind are:

  • modify parameters.yml on beginning of deployment
  • use environment variable that will change on each deploy
  • move redis connection settings to another file that will symlink to one of configurations
  • Do you have other ideas or which one is better in you opinion?


    So seems i was trying to overcomplicate things because of my own lack of knowledge.

    I solved the problem using Doctrine Cache namespaces

    I'm using SncRediBundle and the solutions was simply to use this config:

      doctrine:
        metadata_cache:
          client: cache
          namespace: "%kernel.root_dir%"
          entity_manager: default
    
    链接地址: http://www.djcxy.com/p/24282.html

    上一篇: 通过HTTP确认SNS订阅时发生AuthorizationError

    下一篇: 在部署中清除redis中的doctrine缓存