简体   繁体   中英

Using Memcached in CodeIgniter 3.0

Here is my model file;

function yaklasan_maclar_tenis() {
           $data = $this->cache->memcached->get('yaklasan_tenis');
           if (!$data){
              $this -> db -> limit(10);
              $data = array();
              foreach ($this->db->get_where('maclar', array('durum' => '1', 'sonuclandi' => '0', 'tarih >=' => time(), 'spor' => '5'))->result_array() as $row) {
                $data[] = array(
                'id' => $row['id'],
                'matchid' => $row['matchid'],
                'spor' => $row['spor'],
                'ulke' => $row['ulke'],
                'turnuva' => $row['turnuva'],
                'takim1' => $row['takim1'],
                'takim2' => $row['takim2'],
                'tarih' => $row['tarih'],
                'istatistik' => $row['istatistik'],

                );
            }
              $this->cache->memcached->save('yaklasan_tenis',$data, 600);
           }
           return $data;
    }

I'm sure that I installed memcached properly but getting this error when I call this function:

Fatal error: Call to a member function get() on a non-object in /home/mydomain/public_html/system/libraries/Cache/drivers/Cache_memcached.php on line 79

Here is the lines 77-82, Cache_memcached.php file:

public function get($id)
    {
        $data = $this->_memcached->get($id); //this line is 79

        return is_array($data) ? $data[0] : $data;
    }

I made my research on site but couldn't find anything about it. I just found something and tried the suggestion but nothing changed.

Thanks in advance.

Did you load the caching drive?

Something likes:

$this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM