2017 © Pedro Peláez
 

library limited-objects-cache

Simple ArrayAccess objects' cache with a lookup table in memory and fallback to files with serialized data.

image

idct/limited-objects-cache

Simple ArrayAccess objects' cache with a lookup table in memory and fallback to files with serialized data.

  • Thursday, March 8, 2018
  • by ideaconnect
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

idct/limited-objects-cache

Simple ArrayAccess objects' cache with a lookup table in memory and fallback to files with serialized data., (*1)

Sample

The sample below creates a cache for 20 objects in memory. When 20 are hit then first objects are pushed to files, yet attempt to retrieve a key which has been pushed already there will restore the object on top of the stack., (*2)

$cache = new IDCT\LimitedObjectsCache('/tmp/cached', 20);

for ($i = 0; $i < 25; $i++) {
    $random = new stdClass();
    $random->test = $i;
    $cache['id_'. $i] = $random;
}

var_dump($cache['id_24']); //should be from mem
var_dump($cache['id_1']); //should be from disk
var_dump($cache['id_1']); //should be from mem (now)

Contribution

If you have any suggestions please create an issue or pull request., (*3)

The Versions

08/03 2018

dev-master

9999999-dev

Simple ArrayAccess objects' cache with a lookup table in memory and fallback to files with serialized data.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Bartosz Pachołek