PHP Classes

Variables Caching: Cache variable values generating classes

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 137 All time: 9,240 This week: 560Up
Version License PHP version Categories
variables-caching 1.0GNU General Publi...5PHP 5, Cache, Code Generation
Description 

Author

This class can cache variable values generating classes.

It can set the value of a variable to be cached by generating the code for a class that stores the value of the variable in the class code.

The generated class name is set to the variable name. The class file is stored in a configured class value.

The class can also retrieve the cached variable value by loading the class file if it exists.

It can also delete the cached variable removing the class file.

Innovation Award
PHP Programming Innovation award nominee
October 2015
Number 6
One way to speed up the access to frequently requested information is to create cache files that store that information, thus avoiding the overhead of computing the information again next time it is necessary.

This class implements an unusual approach to store values of variables in cache files.

It generates class files with variables that hold the cached variable values. The generated classes have a name based on the name of the variable to cache.

The class can use auto-loading to load the class of the variable with the cached values.

Manuel Lemos
Picture of Yerfry Ramirez
  Performance   Level  
Name: Yerfry Ramirez is available for providing paid consulting. Contact Yerfry Ramirez .
Classes: 7 packages by
Country: Sweden Sweden
Age: ???
All time rank: 183918 in Sweden Sweden
Week rank: 109 Up2 in Sweden Sweden Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
require 'varCache.class.php';

$cache = new varCache('cache/');

$cache->assign('test', 'result 1'); // can even cache arrays which will be stored in cache/ as previously defined in varCache();
$cache->tempAssign('test', 'result 2'); // remporarily reasings the variable "test"'s value
#echo $cache->delete('test'); // removes both the temporary assigned var and the cached one.
echo $cache->getAssigned('test'); // you can even write in an integer as a key
is_integer()
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:137
This week:0
All time:9,240
This week:560Up