Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter cache returns always empty

I'm try to use the Codeigniter cache system, to cache some remote xml files into "file cache".

Every think looks great when I request the xmls, but codeigniter not cache the files, instead it return a empty cache, and the cache file contains just the data below:

a:3:{s:4:"time";i:1379515910;s:3:"ttl";i:120;s:4:"data";b:1;}

I'm using the code below to cache the xml:

$this->load->driver('cache');
$this->cache->file->save('first', $data, 120);

[UPDATED]

Now I can save the cache, but I can't rescue the saved data. When I run the command below the cache return false

$this->cache->get('show');

Where am I going wrong?

Thanks.

like image 817
GodFather Avatar asked Feb 16 '23 05:02

GodFather


2 Answers

You've saved it using

$this->cache->file->save('first', $data, 120);

Then get it using the right key and it should be first

$this->cache->get('first');

Also, to get information about cache you can use

var_dump($this->cache->cache_info());

Or you may use

var_dump($this->cache->get_metadata('first'));

This is useful for debugging. The get method accepts cache_item_id as parameter that you have used when you saved it

get(id['string'])

Check the documentation.

like image 144
The Alpha Avatar answered Feb 23 '23 11:02

The Alpha


Problem solved, when I call the method to get the current cache I need to pass the used driver e.g.:

$this->cache->file->get('home');
OR
$this->cache->memcached->get('home');

Thanks.

like image 24
GodFather Avatar answered Feb 23 '23 12:02

GodFather