Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Is it possible assign dynamic connection in "modelsCache" DI for specific or some model?

My company has a large website with mixed hardcode and our own framework but our framework is too old and never developed for a long time.

So, I try to figure out how each popular framework can be fit in our website and I really interesting with Phalcon because of Stand-alone Model/Volt feature which can reuse inside and outside framework (for hardcode area).

Each of structure of Phalcon is very suitable for our need, but we found issue about Caching in the ORM (reference:

Our main cache system is Memcached, and we separate each cache server for services or model, such as:

  • Memcache server 1 for "Novel" model.
  • Memcache server 2 for "Calculator" model.
  • Memcache server 3 for else other model. And we can't find a way to use the same infrastructure logic for Phalcon.

We're stuck with this issue for two days, and we can't hook or inject dynamic connection for specific model in DI named "modelsCache".

So, we really need help for this issue.

edited Sep '15

You can pass a service name to override modelsCache to have different connections:

$products = Products::find(
        "cache" => array(
            "service" => "myOtherCache"