Let your application join

Everybody is talking about caching to increase performance but noone tells you exactly what to cache.
One simple strategy is to cache all database access.

We’ve built a data access layer that will cache every single dataset and lists of IDs for conditional sets.
There is no join on the database layer. This is all done by the application.
If you call a page twice, the second request won’t do any database queries to retrieve the displayed¬†data.
It comes all from the cache. Changing data will update the cache and deleting will invalidate it.

Until now, the system runs very smooth and fast.
I’ll share future experiences by the time.

It’s very cool not to have to write database queries any more :-)

Eliminate deterministic function calls

Deterministic function calls always lead to wasted performance. They have to be computed every time but will always return the same boring result. Let’s get rid of them!

Assume your abstract controller provides a translation function $controller->translate()


will always return “Hello World”. We can easily replace the function call with the static content.

It’s getting a little more tricky as soon as you pass some parameters to the function.

$this->translate('helloUser', $username);

The main translation part still is static, so let’s just replace the dynamic part.

sprintf('Salut %1$s', $username);

Built-in functions like sprintf will always be faster than your custom-made translate-and-replace stuff.

Finally store the pre-processed script for each language and let you autoloader choose which one to use.