Project

General

Profile

Actions

Caching

The Problem

Some content is rather static and might be accessed many times.
It might require many resources to build this content (db-queries, processing of the data, ...) so it would be more efficiënt to do the processing once and cache the result.

A good example of this is the handbook application.
To build the table of content we need to retrieve all items in a handbook (keeping things like the chamilo help/documentation in mind, you can imagine this might be a lot of co's). even worse, for every item all context-links need to be retrieved and the most relevant version/variant (in most cases: correct language) has to be determined to display it's title in the table of content.

The building of this table of content has to be done at every page request which will inevitably slow down the application. When a user uses an application like the handbook, you can expect them to do many page request in the same publication, while browsing to the content of a handbook (going back and forward between topics many times).

so this table of content will be build many many times, while it will probably be exactly the same at every page request.

The Solution

caching is really necessary!
Probably some other applications with a lot of semi-static content could use caching too (portfolio, platform-groups, ...) so it would be a good idea to implement the same caching mechanism system-wide.

Caching systems like memcached could be considered but require an extra app to be installed on the server so should be made optional.
Another option might be to serialize the data to be cached and store this in a database-table (what about cleaning up this cached data when it is no longer needed?).

The idea is to use a factory to determine how data will be cached and retrieved (if memcached or some other mechanism is installed/activated use that, otherwise default to caching in the database?) so different caching mechanisms could be implemented over time and platform admins could choose the most appropriate one for their specific situation (somewhat similar to how the different authentication methods are handled?).

The applications will simply do something like Cache::cache_this($identifier, $application, $thingtocache) and Cache::retrieve_cached($identifier, $application) without having to be concerned about the actual procedures to cache and retrieve stuff.

Remarks

Sven: Is this going to be implemented before the merge of may?
Nathalie: it doesn't have to be but handbook (=documentation) is not releasable/usable without it (and with "it" I mean some kind of caching in the handbook-app, not necessarily a system-wide application). For the moment caching functionality has been put in an optional app so it can be used by the applications that need it.

this has been implemented - for the time being - as an optional application "chamilo app caching"

Updated by Nathalie Blocry over 11 years ago · 8 revisions