Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2019-06-12 (3 hours ago) | | Not enough user ratings | | Total: 77 | | All time: 9,359 This week: 536 |
|
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. | |
|
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!
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.