Communicating an array across AJAX boundaries
Jamroom Developers
Stored in memory across sessions, yup that's a difficult ask. :p
The jrCore_get_temp_value() function set do not have a cache system built into it, so it will be accessing the db for each request.
A quick look for functions that do have a caching system in them turned up this one from the jrBanned module that might be useful to you:
function jrBanned_get_banned_config($type)
{
if (!is_array($type)) {
$type = array($type);
}
$key = "jrbanned_is_banned_" . json_encode($type);
if (!$_rt = jrCore_get_flag($key)) {
if (!$_rt = jrCore_is_cached('jrBanned', $key, false, false)) {
$tbl = jrCore_db_table_name('jrBanned', 'banned');
$req = "SELECT ban_type AS t, ban_value AS v FROM {$tbl} WHERE ban_type IN('" . implode("','", $type) . "')";
$_rt = jrCore_db_query($req, 'NUMERIC');
if (!$_rt || !is_array($_rt)) {
$_rt = 'no_items';
}
jrCore_set_flag($key, $_rt);
jrCore_add_to_cache('jrBanned', $key, $_rt, 0, 0, false, false);
}
}
if (!$_rt || !is_array($_rt) || count($_rt) === 0) {
return false;
}
return $_rt;
}
What its doing is checking if there is a flag ( IN MEMORY ), if no, check if there is a cached item ( FILESYSTEM / MEMORY ), if not, get it from the database ( DATABASE ).
So if its a performance issue reason you want to bypass the database, that structure looks about as good as you could get i reckon.
Adjust as needed for your own module and situation.