Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Add LswMemcache to multiple Doctrine entity manager #59

Open
odoucet opened this issue Sep 30, 2015 · 5 comments
Open

Add LswMemcache to multiple Doctrine entity manager #59

odoucet opened this issue Sep 30, 2015 · 5 comments
Assignees
Labels

Comments

@odoucet
Copy link

odoucet commented Sep 30, 2015

Documentation already gives information about how to add LswMemcacheBundle support on Doctrine (see https://github.com/LeaseWeb/LswMemcacheBundle#doctrine-support)
But even if this is well handled for default entity manager, it seems it does not work for multiple entity managers :

When using executeCacheQuery() we get :
Trying to cache a query but no result driver is configured.

Another way to check :

dump($this->get('doctrine')->getManager('metrics')->
    getConnection()->getConfiguration()->getResultImpl()); 
// dump NULL

Copy of YAML :

lsw_memcache:
    pools:
        default:
            servers:
              - { host: 127.0.0.1, tcp_port: 11211 }
    doctrine:
        metadata_cache:
            pool: default
            entity_manager: [default, metrics]
            document_manager: default
        result_cache:
            pool: default
            entity_manager: [default, metrics]
            prefix: "result_"
        query_cache:
            pool: default
            entity_manager: [default, metrics]

If we try to add the cache class ourself, we end with an error :

$cache = $this->get('memcache.default');
$config = $this->get('doctrine')->getManager('metrics')->getConnection()->getConfiguration();
$config->setResultCacheImpl($cache);

This gives this error :
Argument 1 passed to Doctrine\DBAL\Configuration::setResultCacheImpl() must implement interface Doctrine\Common\Cache\Cache, instance of Lsw\MemcacheBundle\Cache\AntiDogPileMemcache given.

@mevdschee
Copy link
Contributor

When you try to add the cache yourself, you should instantiate a "Lsw\MemcacheBundle\Doctrine\Cache\MemcacheCache" class and then call "setMemcache()" on the created object to set the client.

@odoucet
Copy link
Author

odoucet commented Oct 1, 2015

OK, updating the doc will be great about it :)

@mevdschee
Copy link
Contributor

Well, we still have not figured out why "executeCacheQuery" gives an error and why it seems it does not work for multiple entity managers. Or did you find reasons for that?

@mevdschee mevdschee self-assigned this Oct 1, 2015
@mevdschee mevdschee added the bug label Oct 1, 2015
@odoucet
Copy link
Author

odoucet commented Oct 2, 2015

Not yet, And I have to admit I've changed my code after I encountered this
bug to cache the query result myself.

2015-10-01 22:58 GMT+02:00 Maurits van der Schee [email protected]:

Well, we still have not figured out why "executeCacheQuery" gives an error
and why it seems it does not work for multiple entity managers. Or did you
find reasons for that?


Reply to this email directly or view it on GitHub
#59 (comment)
.

@mevdschee
Copy link
Contributor

OK, thank you. I will try to reproduce it and update this thread.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants