Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear Doctrine cache stored in Redis

I start using Redis on me project (php-redis). Is a Symfony2 project and i found the:

https://github.com/snc/SncRedisBundle

I follow the installation process and i configured:

  • Some clients to store no-sql data and cache
  • Sessions storage
  • Doctrine metada, result and query cache

I create a new entity in a bundle and i fail because i create it at yml and i have all others with annotation system, so i delete yml format and create the annotation.

Every change i make on the annotation class (change the table name for example), is not affecting the schema or the database, even i recreate the database or try to execute cache:clear with all the options.

If i just comment the redis doctrine configuration lines, it works and i can see the changes on the schema.

Im maybe forgetting something, or i cant really find how to clean that doctrine redis cache.

¿I have to manually clean any position on the redis client use for caching?

Here is the configuration:

#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
like image 763
ruudy Avatar asked Nov 01 '22 16:11

ruudy


1 Answers

The easiest way but not the best one is to flush redis db with doctrine cache. Run

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

(Not tested!) Another way is to setup doctrine metadata cache in doctrine config 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:                ~
like image 65
Jekis Avatar answered Nov 13 '22 05:11

Jekis