Little caching/performance proposal |
[eluser]Unknown[/eluser]
I have a little proposal how to speed up a little codeigniter caching. If I understand caching properly, all the magic starts when I'm calling Code: $this->load->view('some_view'); Could someone help me writing an extension to check if current site is cached (and not expired) that I could do something like that: Code: if(cache_expired()) { I think that extending Output class could be an issue. But maybe there is such function (or similar) so I don't want to discover a wheel again ![]() Thanks for help.
[eluser]Jelmer[/eluser]
Try building something like that on my MP_Cache library (Wiki article). Easiest option would be to add an expires-key to the cached array and test for that as well as for the cache, like this: Code: $this->load->library('MP_Cache'); EDIT: I have thought about adding something like this to the get() function (like allow a second parameter with the number of seconds it takes to expire). But I didn't really see the upside to this implementation as I tried to keep the library as general-use as possible, and the example above should do the trick just as well with just a little extra code.
[eluser]Unknown[/eluser]
I'm using this Output library for caching header info http://codeigniter.com/wiki/Cache_headers So I wrote such function extending it: Code: function _cache_expired() { Code: unserialize($cache); Code: $this->cache = unserialize($this->cache); My tests show that using this function isn't faster than not using it at all ![]() I will change this function from unserialize version to checking mtime of cached file - maybe this will be faster. I will post if it helps. |
Welcome Guest, Not a member yet? Register Sign In |