PHP code example of jnilla / joomla-cache-helper

1. Go to this page and download the library: Download jnilla/joomla-cache-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jnilla / joomla-cache-helper example snippets




$cache = CacheHelper::callback(
	'idHere', // Cache Id
	'groupNameHere', // Cache Group
	function(){return file_get_contents('https://jsonplaceholder.typicode.com/todos');}, // Callback that returns the data to cache
	6, // Cache Lifetime
	15 // Wait if updating
);

// $cache var dump
array (size=4)
  'isValid' => boolean true
  'isUpdating' => boolean false
  'isTimeout' => boolean false
  'data' => string '{some JSON code from that source}' (length=0)