I need a help to figure out one issue with the codeigniter caching.
I am running two functions to store a result in cache. This function is in my model :
public function cacheAllCurrencies()
{
$this->db->cache_on();
$this->db->select("name,icon,currency_code");
$this->db->from("currency");
$this->db->where("status='Active'");
$cache_currency_result = $this->db->get()->result();
$this->db->cache_off();
return $cache_currency_result;
}
public function cacheAllCategory()
{
$this->db->cache_on();
$this->db->select("name,url");
$this->db->from("category");
$this->db->where("parent_category='0'");
$this->db->where("status='Active'");
$this->db->order_by('name','ASC');
$cache_category_result = $this->db->get()->result();
$this->db->cache_off();
return $cache_category_result;
}
My these two functions are called in header view like below :
$CI =& get_instance();
$CI->load->model(PUBLIC_DIR.'/commonPage','common');
$currencies = $CI->common->cacheAllCurrencies();
$categories = $CI->common->cacheAllCategory();
Now, when all the page loads, it creates a cache file according to the page opened like home, blog, blog+blogname etc.
Both query generates two cache file in cache folder
1580e4c2413cb09f6ed3bc7fae8cee45
- first function cache result
d7e2452b0424f859e1a5984bd26cbd6c
- second function cache result
Now, I have two questions :
- I need to delete 1580e4c2413cb09f6ed3bc7fae8cee45 cache file when I update currency table same for the category.
- How this file name generated ? I mean how
codeigniter
generates cache file name. In my cache1580e4c2413cb09f6ed3bc7fae8cee45
for currency andd7e2452b0424f859e1a5984bd26cbd6c
for category.
I hope this explanation makes sense and I hope most of the codeigniter
developer having this problem which need to be sort it out.
Thanks, Ali
In Codeigniter, you can clear the cache of DB using the table name like
OR two table cache at the same time
EDIT : CodeIgniter save filename by md5() encryption of SQL query