2017 © Pedro PelĂĄez
 

library cache

A lightweight file-system cache library

image

sebsept/cache

A lightweight file-system cache library

  • Thursday, January 16, 2014
  • by SebSept
  • Repository
  • 2 Watchers
  • 3 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 23 Forks
  • 4 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

Cache

This is a light weight file cache component for php., (*1)

Features

  • Lightweight (~8Kb)
  • Simple to use (see API)
  • 100% Unit tested
  • Optionnaly define expiration delay when retrieving content ( not when creating the cache )

Usage

Basic

<?php
// include file (using composer)
require('vendor/autoload.php');

// create an instance of Cache() with default params
$cache = new \SebSept\SimpleFileCache\Cache();

// create an instance, setting expiration delay (2 hours) 
// and cache dir and cache dir depth
$cache = new \SebSept\SimpleFileCache\Cache(
array(
    'directoryPath' => '/tmp/cacheFS',
    'delay' => 60*60*2, 
    'pathDepth' => 2
)
);

// create a cache
$cache->set('theCacheId', 'This is some cached content, string');

// get cached content
$content = $cache->get('theCacheId');

// get cached content not older than 120 secondes
$content = $cache->get('theCacheId', 120); // content is null if cache expired or not existing


// delete a cache
$cache->delete('theCacheId');

Other methods

// check that a cache with id 'theCacheId' exists and is less than an hour
$cache->exists('theCacheId', array('delay' => 60*60));

// full path to file on disk
$pathToFile = $cache->getFilePath('theCacheId');

// path to base dir where cache files are
$cacheDirPath = $cache->getDirectoryPath();
// change path depth
$cache->setPathDepth(3); // files will be stored in /CacheDir/1/2/3/thecachename

// change cache directory
$cache->setDirectoryPath('/tmp/newdir'); 

Installation

Composer

Add this to your composer.json :, (*2)

{
    "require": {
        "sebsept/cache": "dev-master"
    }
}

Git

git clone https://github.com/SebSept/SimpleFileCache.git

Direct download

History

This is a fork of https://github.com/Gregwar/Cache . I found and install Gregwar/Cache from composer but found a bug : Expiration was not respected, so took a look at the code ... then decided to recode it all., (*3)

License

Published under The MIT License (MIT)., (*4)

The Versions

16/01 2014

dev-master

9999999-dev https://github.com/SebSept/SimpleFileCache/

A lightweight file-system cache library

  Sources   Download

MIT

cache caching simple file-system

15/01 2014

dev-wip

dev-wip https://github.com/SebSept/SimpleFileCache/

A lightweight file-system cache library

  Sources   Download

MIT

cache caching simple file-system

12/01 2014

1.0-rc

1.0.0.0-RC https://github.com/SebSept/SimpleFileCache/

A lightweight file-system cache library

  Sources   Download

MIT

cache caching simple file-system