First-level cache in Agile Data?


Hi, I am finding my ways around “Agila Data”.
Can you help me understand how it deals with a problem of multiple DB requests?

For example, we have a command handler and authorizer classes, first executes a command, second authorizes a user to do so. Both are decoupled and both can query the same kind of information from a DB.

Is there a mechanism in Agile Data which will cache responses or somehow reduces the number of similar/equal requests?



Hi Dima.

I’m not fully understanding the command/authorize pattern, but to answer your question on reducing queries:

  1. Agile Data tries best not to perform multiple queries in the first place. Here are some usage patterns:

  2. When you wish to cache things elsewhere, then you can load models from a different persistence. A good example is here:

Technically, Model you can attempt to load Model from any persistence:

$persistence->tryLoad($user, $cache_key);

I haven’t coded persistence implementation for Memcache or Redis, but that’s something I was meaning to do for some time.