Forums

How about caching data?

anne1979 01 May, 2016
Hi again,

in my components built with both CC v5 and CC v5 I would like to write some data (array / list data) to a cache so that several queries would only run if the variable isn't present in cache... The list data isn't changing in 24 hours and the lists are the same to all users...

How can I do that? Did one of you already try to work with caching of data?

I will have to:
[list]- ask, if the certain list is available in cache (get it back from cache)
- if not, run the query and put the list variable into cache to be valid until a certain time
[/list]

Let me point out, that I am not used to PHP and its caching mechanisms...

Thanks for helping me out,
Anne
GreyHead 02 May, 2016
Hi Anne,

If the current user session is enough you can use the Joomla! User session to save data.

CF has Data to Session and Session to Data actions you can use (the Multi Page action is a wrappre for them). Or, perhaps easier you can use custom code
<?php
$jsession = \JFactory::getSession();
$jsession->set('name', 'value');
$jsession->get('name', 'default_value');
?>
If you want to save multiple values you could json_encode it before saving.

Bob
This topic is locked and no more replies can be posted.