PHP Classes

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

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 237 All time: 8,067 This week: 206Up
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: 42
All time rank: 2699372 in United States United States
Week rank: 227 Up23 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 (5)  
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 (5)  /  cache  
File Role Description
  Accessible without login Plain text file example.php Output Sample output

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:237
This week:0
All time:8,067
This week:206Up