Jon Beverley
Jon Beverley

Reputation: 101

Doctrine Second Level Cache not doing anything

I have a bunch of entities and would like to test the Second Level Cache but I can't get it to work. I just get zero hits, misses & puts in the profiler.

All entities have annotations as below.

use Doctrine\ORM\Mapping AS ORM;

/**
 * @ORM\Entity
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="my_region")
 */
class Property extends Base\PropertyBase
{

My config file has -

doctrine:
    orm:
        metadata_cache_driver:
                type:           memcache
        result_cache_driver:
                type:           memcache
        query_cache_driver:
                type:           memcache
        second_level_cache:
            region_cache_driver:
                type:           memcache
            enabled:              true
            log_enabled:          true
            regions:
                my_region:
                    cache_driver:  memcache
                    lifetime:   3600

The profiler shows the cache is enabled but I am not getting any activity.

Any suggestions as to how I might debug this?

Upvotes: 3

Views: 3099

Answers (1)

Jon Beverley
Jon Beverley

Reputation: 101

My metadata was cached in memcache so when I edited the entity files to add the cache annotations they were not picked up. I was clearing the app/cache folder but this was being repopulated from memcache rather that the entity files. Clearing the cache sorted it.

Its working very well now!

Upvotes: 7

Related Questions