PHP Classes

PHP Array Cache File: Store array values in PHP cache file scripts

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 237 This week: 1All time: 8,056 This week: 560Up
Version License PHP version Categories
arraycache 1.0.0MIT/X Consortium ...5PHP 5, Files and Folders, Cache, Code..., C...
Description 

Author

This class can store array values in PHP cache file scripts.

It can take a array value and an optional file name and store the array in a PHP cache script.

The generated script can load the original array value using a require statement.

Picture of troy knapp
Name: troy knapp is available for providing paid consulting. Contact troy knapp .
Classes: 2 packages by
Country: United States United States
Age: 41
All time rank: 2696372 in United States United States
Week rank: 411 Up48 in United States United States Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
namespace ArrayCache;
/**
 * Class: $classStr
 * User: troy
 * Date: 5/7/2016
 * Time: 9:24 AM
 */
require_once 'ArrayCache.php';

$array = array(
   
123,
   
'animals' => array(
       
'dog',
       
'cat',
       
'mouse',
       
'bird'
   
),
   
'key' => 'value',
   
'foo' => 'bar'
);
$filename = dirname(__FILE__) . '/cache/example.php';

$ac = new ArrayCache($array, $filename);

$cachedArray = require_once $filename;

var_dump($cachedArray);


Details

ArrayCache

Stupid simple class capable of creating php files that return arrays.

This is a very basic class that just saves arrays in a file that return said array. I created this class primarily because I'm exceedingly lazy, and I wanted to go through as minimum of an effort as possible to save and retrieve config values.

Ultimately, I think that if you need a way to store data that will not be written very often, that's lightning fast to access, who's data can be version controlled, you don't want the extra overhead of having a db connection, and/or you don't want to json_decode or unserialize your data to stick it into an array, then this class may be for you.


  Files folder image Files  
File Role Description
Files folder imagecache (1 file)
Plain text file ArrayCache.php Class Class source
Accessible without login Plain text file Example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  cache  
File Role Description
  Accessible without login Plain text file example.php Output Sample output

 Version Control Unique User Downloads Download Rankings  
 100%
Total:237
This week:1
All time:8,056
This week:560Up