cache data in codeigniter

Solutions on MaxInterview for cache data in codeigniter by the best coders in the world

showing results for - "cache data in codeigniter"
Kais
15 Apr 2016
1if (! function_exists('getCacheSettings')){
2	function getCacheSettings($key)
3	{
4		if ($cacheSettingValue = checkCachedValue($key)) {
5			return $cacheSettingValue;
6		}
7
8		$ci = & get_instance();
9		$result = $ci->db->get_where('settings', array('key' => $key));
10
11		if ($result->num_rows() > 0) {
12			$fetchData = $result->row();
13			cacheFetchedData($key, base64_decode($fetchData->value));
14			return base64_decode($fetchData->value);
15		}
16		return null;
17	}
18}
19
20if (! function_exists('checkCachedValue')){
21	function checkCachedValue($key)
22	{
23		$ci = & get_instance();
24		$ci->load->driver('cache', array('adapter' => 'file'));
25		$cacheKeyData = $ci->cache->get("icd10_".$key);
26
27		return !empty($cacheKeyData) ? $cacheKeyData : false;
28	}
29}
30
31if (! function_exists('cacheFetchedData')){
32	function cacheFetchedData($key, $fetchedData)
33	{
34		$ci = & get_instance();
35		$ci->load->driver('cache', array('adapter' => 'file'));
36		// Save into the cache for 12 Hours
37		$ci->cache->save('icd10_'.$key, $fetchedData, 60 * 60 * 12);
38		return $fetchedData;
39	}
40}
41
42
43getCacheSettings('KEY_NAME');
44
45$this->cache->delete('cache_item_id');
46
47This method will ‘clean’ the entire cache. If the deletion of the cache files
48fails, the method will return FALSE.
49
50$this->cache->clean();
51
52refrence:
53https://www.codeigniter.com/userguide3/libraries/caching.html#example-usage
Michela
12 May 2019
1class MY_Output extends CI_Output
2
queries leading to this page
codeigniter cache querycodeigniter 3 caches query resultsenable cache codeigniter 4codeigniter config cachecache codeignitercache codeigniter 3codeigniter db cachecodeigniter cache specific queries clear codeigniter cacheclear codeigniter cache from controllercodeigniter cache multi directoryquery cache codeigniterhow to clear cache in codeigniter 4how to clear the cache of codeigniterhow to enable cache in codeignitercache reset in codeigniterremove cache in codeigniteroutput cache codeigniterset cache data codeigniterhow to cache in codeignitercodeigniter cache dynamic pagecodeigniter cachecodeigniter cache clearcache pages codeignitercache query codeigniterhow to cache a codeigniter websitehow can we clear a cache automatically from browser using codeignitercodeigniter clear cache every 5 minuteshow to disable cache in codeignitercache codeigniter 4query cache in codeignitercodeigniter clear cachehow to remove cache in codeignitercache single query in codeignitercodeigniter 3 use cachecodeigniter 3 cache implementcodeigniter cache clear commandcache data in codeignitercodeigniter load cache view with datafix cache issues codeigniterbest practices cache database on codeigniterclear cache codeigniter 4clear cache codeigniterhow cache works in codeignitercodeigniter view cachequery cache for certain time in codeignitercodeigniter output cache 24this output cache 28 29 codeignitercodeigniter this 3eview cacheshow can we clear browser cache from codeignitersave file in cache codeignitercodeigniter enable cachehow to clear the cache of codeigniter 4how to accept cache in codeigniterhow to works cache at codeigniter 4codeigniter http cachinghow to clear codeigniter cachephp codeiginiter cachingcache system in codeigniterhow cache in codeignitercodeigniter web page cache based on usercache in codeigniterclear codeigniter cachecodeigniter query cache examplecodeigniter check if data is from cacheclear cache in codeignitercodeigniter 3 web page cachecache query codeigniter 4codeigniter cache exampledatabase cache codeigniter how it workscodeigniter 4 cache queryhow to use cache in codeigniterhow to use cache in codeigniter 4ckear cache in codeigniter 4set cache in codeigniterx c3 b3a cache trong codeignitercache off 28 29 codeignitercodeigniter 4 cachecodeigniter cache implementationcache in codeigniter examplecodeigniter clear cache 3fcodeigniter 3 database cachebrowser cache issue in codeigniterwhat is cache in codeignitercacheing in codeignitercodeiginter save cachecodeigniter 4 database cachecache view for 10 minures codeigniter cachecodeigniter cache delete allcodeigniter clear browser cachecodeigniter driver cache clicache data in codeigniter