Ticket #770 (closed enhancement: fixed)
Integration of memcached support into QCubed
| Reported by: | vaibhav | Owned by: | somebody |
|---|---|---|---|
| Priority: | must | Milestone: | 2.1 |
| Component: | ORM | Version: | 2.0.2 Stable |
| Keywords: | memcached, | Cc: |
Description
Related thread: http://qcu.be/content/qcubed-memcache-integration-complete
QCubed has always been rated as a slow framework and the addition to the framework tries to solve that by adding memcached support.
Please note that the API used is memcache (not memcached).
The following changes have been made:
1. configuration.inc.php has two new definitions. One is boolean value (true/false) used to switch off the memcached functionality altogether. Other is the array which will be used for connecting to various memcached servers (it has only two parameters: the server IP address and the port to connect to).
2. QApplicationBase.class.php has a new public static member which is initialized as a memcache object by prepend.inc.php as and when it is included. The variable remains null otherwise.
3. prepend.inc.php is modified to check whether memcached support is enabled and initializes the variable in QApplicationBase.class.php and adds the server to the pool.
4. Query methods Load, Delete, DeleteAll, Save, Truncate and Reload have been modified in the templates to consider memcached support. The behavior is as follows:
*
Load method sees if the objOptionalClauses is null or not. If it's not null, the query is actually performed on the database.
If the objOptionalClauses is null and memcache support is enabled, the the object is looked up in the cache. If found, it is returned otherwise the query is run on the database.
If the query is run (because of any reason) and memcached support is enabled, the object is added to the cache for later use.
* Save function simply deleted the object from the cache. It is because it will automatically be cached in the Load method the next time the object is requested.
* Delete function will first remove the object row from the database and then remove it from the cache.
* DeleteAll and Truncate will empty all the cached items from the server. This is because these two functions are normally not carried out regularly and there is no way to search for all the keys in the cache and delete them.
* Reload will remove the object from memcache before calling the Load method. this automatically reloads the object in the cache as well!

