Component development: Cache questions - Joomla! Forum - community, help and support
i've searched , searched , struggled find resource explaining how use joomla's caching system.
can recommend resource reading how start using joomla's cache?
i'm developing component , want cache single view. view returns json object , can take little while (10 seconds~) complete, prime candidate caching. i've got working, seems ignoring 'setlifetime' value i'm setting.
i won't post entire code, basics of following:
view.json.php
pulls javascript object model, json encodes , echoes browser.
with no cache, relevant code looked like:
i've managed cache working changing to:
now, above works, sort of. output of function cached , it's much, quicker because of it. ignores 'setlifetime'. in example above, i've set 5, in actual code it's pulling in value component parameters equivalent 3 days (3 * 60 * 24).
however, after few minutes if try reloading page (that calls function) re-executes function without using cache.
what doing wrong?
thanks help,
tom
can recommend resource reading how start using joomla's cache?
i'm developing component , want cache single view. view returns json object , can take little while (10 seconds~) complete, prime candidate caching. i've got working, seems ignoring 'setlifetime' value i'm setting.
i won't post entire code, basics of following:
view.json.php
pulls javascript object model, json encodes , echoes browser.
with no cache, relevant code looked like:
code: select all
$result = $this->get('something');
echo json_encode($result);
i've managed cache working changing to:
code: select all
$cache = & jfactory::getcache();
$cache->setcaching(1);
$cache->setlifetime(5);
$result = $cache->call(array($this, 'get'), 'something'');
echo json_encode($result);
now, above works, sort of. output of function cached , it's much, quicker because of it. ignores 'setlifetime'. in example above, i've set 5, in actual code it's pulling in value component parameters equivalent 3 days (3 * 60 * 24).
however, after few minutes if try reloading page (that calls function) re-executes function without using cache.
what doing wrong?
thanks help,
tom
Comments
Post a Comment