Welcome Guest, Not a member yet? Register   Sign In
How implement cache on Search query sql
#1

Hi guys,


I need to be able to cache all kinds of searches with like.
I have it this way, according to the documentation, but according to the profiler, it doesn't save in cache and the query is still running.


SearchModel
PHP Code:
public function search($product)
 
   {
 
       $this->db->cache_on();
 
       $data $this->db
            
->select('name, slug')
 
           ->from('products')
 
           ->like('name'$product)
 
           ->or_like('slug'$product)
 
           ->limit(5)
 
           ->get()
 
           ->result_array();
         
$this->db->cache_off();

 
       return json_encode($data);
 
   

SearchController:
PHP Code:
public function index($product)
 
   {
 
       $product urldecode($product);
 
       $product preg_replace('/\s+/''-'$product);
 
       $this->load->Model('api/search/SearchModel');

 
       echo $this->SearchModel->search($product);

 
       $this->output->enable_profiler(TRUE);
 
   

[Image: 7152dc383ed4e975467591358008d7db.png]


Directory application\cache is empty...
[Image: 9b422656b418d1b101dce28e2487181a.png]
Reply


Messages In This Thread
How implement cache on Search query sql - by Decibel150 - 12-18-2018, 02:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB