>

<?php
defined('_JEXEC') or die;

use Joomla\CMS\Cache\Cache;
use Joomla\CMS\Factory;

// Set the cache options.
$cache_group = '_footableghsvs';

$options = array(
	'cachebase' => Factory::getApplication()->get('cache_path',
		JPATH_SITE . '/cache'),
	'lifetime' => 360,
	'defaultgroup' => $cache_group,
	'caching' => true
);
$cache = new Cache($options);

/* Create a safe ID for cached data in this case from URL parameters. Not always
clever. */
$cache_key = $cache->makeId();

if ($cache->contains($cache_key) && ($cacheGet = $cache->get($cache_key)))
{
	$cacheGet = json_decode($cacheGet);

	$rows = $cacheGet->rows;
	$cols = $cacheGet->cols;
}
else
{
	// Nothing in cache.
	$cacheGet = false;
}

// Collect some data 
if ($cacheGet === false)
{
	$cols = $firstArrayWithWhatever;
	$rows = $secondArrayWithWhatever;

	// Cache the data for future use..
	$cache->store(
		json_encode(array('rows' => $rows, 'cols' => $cols)),
		$cache_key,
		$cache_group
	);
}

// Do whatever you want with $rows and $cols.