A cached function call / a cache anything function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: A cached function call / a cache anything function (/showthread.php?tid=53406) |
A cached function call / a cache anything function - El Forum - 07-23-2012 [eluser]Patrick Savalle[/eluser] Copy /system/libraries/Cache/Cache.php to /application/libraries/Cache and add the method below to the class. You now have function that can cache every other function's result. Use it only for TRUE / context-free functions, i.e. functions whose result only depend on their arguments. It uses the standard codeigniter caching mechanism: http://ellislab.com/codeigniter/user-guide/libraries/caching.html It is equivalent to the standard PHP function call_user_func_array: http://php.net/manual/en/function.call-user-func-array.php --> To the codeigniter team, please add this to the new release. Code: /** Example of usage: Code: $cache_adapter = 'apc'; Don't overuse this function. Only cache costly operations that form a performance bottleneck and never rely on the cache to actually store anything. A cached function call / a cache anything function - El Forum - 07-23-2012 [eluser]PhilTem[/eluser] [quote author="Patrick Savalle" date="1343047665"]... --> To the codeigniter team, please add this to the new release. ...[/quote] Make either an issue on GitHub or a pull request on the latter page. The CI team isn't here too often neither do they take anything serious that is posted here, as they also mention "(please post issues and pull requests to GitHub)" A cached function call / a cache anything function - El Forum - 07-23-2012 [eluser]Patrick Savalle[/eluser] Yes, I tried that. Github is way above my mental capacities. Sorry, I am a software developer, not a rocket scientist But be my quest. A cached function call / a cache anything function - El Forum - 07-23-2012 [eluser]Patrick Savalle[/eluser] https://github.com/EllisLab/CodeIgniter/issues/1646 |