Cache System
As of v0.9.0 eoCMS allows the caching of simple queries into a file. In other words, it saves the data inside the file in an attempt to speed up the page load and reduce the load on the database.
The cache system is unique in the way it works. It is not based on time like other caches but rather it checks the contents of the sql_query function to see if it is updating or modifying a table in any way. If it finds a query like that then it will check to see if it is a table which has a cached query within a file called tables.txt stored in the cache/ folder. If it matches the tables then it will delete the previous cache and create a new one. Why not timed? Well why make a new cache file for something that hasn’t changed.
Currently, only simple SELECT queries are supported. JOINS will not work and may cause errors. To cache a query, use the sql_query function as normal but add an extra argument to the call() function like so:
call('sql_query', "SELECT * FROM emoticons", 'cache');
The ‘cache’ tells eoCMS to cache that query and use the data stored in the file from now on. The variable which you set this query to is now an array so please take note of this.
What to cache?
Only cache queries which will rarely be updated for example the emoticons. The way eoCMS stores the data is as follows:
die();
serialized array here
Due to this, all of the data is safe, it cannot be accessed by the outside world. So sensitive data such as passwords are ok but not recommended.
The cache system is unique in the way it works. It is not based on time like other caches but rather it checks the contents of the sql_query function to see if it is updating or modifying a table in any way. If it finds a query like that then it will check to see if it is a table which has a cached query within a file called tables.txt stored in the cache/ folder. If it matches the tables then it will delete the previous cache and create a new one. Why not timed? Well why make a new cache file for something that hasn’t changed.
Currently, only simple SELECT queries are supported. JOINS will not work and may cause errors. To cache a query, use the sql_query function as normal but add an extra argument to the call() function like so:
call('sql_query', "SELECT * FROM emoticons", 'cache');
The ‘cache’ tells eoCMS to cache that query and use the data stored in the file from now on. The variable which you set this query to is now an array so please take note of this.
What to cache?
Only cache queries which will rarely be updated for example the emoticons. The way eoCMS stores the data is as follows:
Code:
die();
serialized array here
Due to this, all of the data is safe, it cannot be accessed by the outside world. So sensitive data such as passwords are ok but not recommended.
28th April, 2009, 09:57:59 AM
2560
Ratings
Comments
No Comments