PHP Classes
elePHPant
Icontem

Tuadmin Cache: Cache variable value in file or session variable

Recommend this page to a friend!
  Info   View files Documentation   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-06-12 (3 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 77 All time: 9,359 This week: 536Up
Version License PHP version Categories
tuadmin-cache 1.0.1The PHP License5.4PHP 5, Files and Folders, User Manage..., C...
Description Author

This package can cache variable value in file or session variable.

It takes a name of a cached value and checks if it is store in the cached container.

If the cached value is not stored or has expired, it calls a given callback value to return the new value to be cached.

The package comes with classes to store cached values in either files or session variables.

The cached values expiry time is configurable.

  Performance   Level  

Details

tuadmin.cache

system for caching data

-(new file($PATH_FOLDER_CACHE))->{ANY_ID}($callback,$seconds_cache)
-(new session())->{ANY_ID}($callback,$seconds_cache)

Cache in static files

<?php
require 'tuadmin\cache.php';
$cache = new tuadmin\cache\file(__DIR__ .'/tmp');

Cache in session

<?php
require 'tuadmin\cache.php';
$cache = new tuadmin\cache\session(md5('var_in_session'));//alternative for name ,cache in $__SESSION[md5('var_in_session')]

Use object cache

$cache_expire_in=3600;//seconds
$variable_key= '123';//for use in identifier
$var = $cache->{"id_is_$variable_key"}(function()use($variable_key){
	return array(time()." this is cached for var".$variable_key);
},$cache_expire_in);

echo $var[0];

example for only tuadmin\cache\file and result is ever string

echo $cache->_("id_is_for_ever_string",function(){
	return time()." this is cached for var";
},60);

Haga clic aquí para prestar su apoyo a: donaciones para más proyectos y hacer una donación al PAYPAL!

  Files folder image Files  
File Role Description
Files folder imagetemp (2 files)
Files folder imagetuadmin (1 file, 1 directory)
Accessible without login Plain text file example_file.php Example Example script
Accessible without login Plain text file example_session.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login HTML file README.html Doc. Documentation
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:77
This week:0
All time:9,359
This week:536Up