Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 Entities\PlayerRecord::$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:

  1. modify parameters.yml on beginning of deployment
  2. use environment variable that will change on each deploy
  3. 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?

like image 612
Gustek Avatar asked Jan 20 '15 16:01

Gustek


1 Answers

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
like image 50
Gustek Avatar answered Oct 01 '22 15:10

Gustek