PHP code example of peterujah / cache

1. Go to this page and download the library: Download peterujah/cache 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/ */

    

peterujah / cache example snippets


use Peterujah\NanoBlock\Cache;
$cache = new Cache("CACHE_NAME", __DIR__ . "/temp/caches/");

$cache->setExpire(7200);
$user = $cache->onExpired("LIST", function () use($connConfig, $user_id){
	$conn_handler = new Peterujah\NanoBlock\DBController($connConfig);
	$conn_handler->prepare('
	      SELECT * FROM user_table
	      WHERE user_id = :fund_user_id
	      LIMIT 1
	');
	$conn_handler->bind(':fund_user_id', $user_id);
	$conn_handler->execute();
	$user = $conn_handler->getOne();
	$conn_handler->free();
	return  array(
	    "user" => $user,
	    "time" => time(),
	    "morething" => "More"
	);
});

$cache->setDebugMode(true|false);

$cache->setExtension(Cache::PHP | Cache::JSON | Cache::TEXT);

$cache->enableSecureAccess(true | false);