Welcome Guest, Not a member yet? Register   Sign In
Cache question
#1

[eluser]growknight[/eluser]
Hi
Is it good or bad solution for a medium traffic user updated network site?

Code:
// my model
    
    function get_clubs($params)
    {
        if (!empty($params['line']))
            $this->db->where('line', $params['line']);
        #some param
        $rows = $this->db->get('clubs')->result();
        
        foreach ($rows as $row)
        {
            $this->cache->model('clubs_m', 'get_club', array($row->club_id));
        }
    }
    
    function get_club($id)
    {
        $this->db->select('
            *, club_id AS ID
        ');
        #some joins...
        $this->db->where('club_id',$club_id);
        $this->db->get('clubs');
    }
#2

[eluser]Eric Barnes[/eluser]
Personally just from the looks of it you are caching a lot of files for really no reason. I would instead use it like this:
Code:
function get_clubs($params)
{
  if ( ! $data = $this->cache->get('get_clubs_'.implode($params, '_'))
  {
    // Do queries and everything
    
    // Set all my return stuff to $data array
    $data = $rows;
    $this->cache->save('get_clubs_'.implode($params, '_'), $data, 600);
  }
  return $data;
}




Theme © iAndrew 2016 - Forum software by © MyBB