Ideas for an improved Query Caching solution.

Ive just implemented caching by controller->method() in

Already implemented to controllers and to models.

The beauty of it that is transparent to the method cached, you implement yourmethod(), call yourmethodCached() and that's it, nothing of the tradicional

// You dont need to do this.
if (($result = cached(....)) === FALSE) {
    $result == lenghtyCode(); // your code to be cached;

instead you do:
// You inplement
function mymethod($args) {
    // zero instrumentation to cache. LOOK MA, NO HANDS!

// You call..
$cachedresult = $this->mymodel->mymethodCached($args); //model or controller

With little effort this can be used to cache tradicional partial views, need to do the caching in the load object to create a load->viewCached() (already caching partial views in HMVC as the methods in the controller are cacheable with the current code).

Usable to anyone?

[eluser]Maks Baum[/eluser]
And what about changin application / cache_database / controller_based / controller + function / md5hash
becouse in DB_cache we see : $uri .= ($this->CI->uri->segment(2) ...
And look:
We got a news site, we can read news under... where 1234 is news id
In routers we map /news/[num] into news/show_news/[num] so every cache made from DB it stores in folders under cache/ .. cache/news/1234 cache/news/1235 cache/news/1236 and when we cache in all this pages additional DB query which we want to have then its stored in different folders, so every time data is taken from DB
So instead of makin /cache/news1234 I think it should take the /cache/show_news/ - method name != second uri segment always.

I think CI can do with a simple key=>value cache next.
It can be implemented relatively easily and is general enough to be used in a variety of ways.
For now, I'm using the APC cache but I suppose a native CI key-value cache will be useful to abstract the actual cache implementation (file, apc or memcache etc). Especially for those using CI in a shared environment.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.