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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With