AhCache

Description

This is a PHP class to store and cache data as a file. You can use this class without any additonal service on any hoster. It does not require any library, framework or database.
I wrote it to cache data for the website of Swiss public radio (DRS/ SRF) where it was in use for several years.

You can store any data you can handle with the serialize function: integers, strings/ texts, arrays, objects. In other words: 99.9% of all data you can fetch from internet services or database resultsets.

If it is called a cache you need to know, when it is outdated an when you must refresh your cached data.
You can put a TTL (in sec) to your data. Or you can compare the cache with another local file.
Additionally you have methods to see the age of your cache, is it outdated already or not.

If you create data you must be able to cleanup them. This class offers to delete a single cache item, all cached items of an application or all cached items of all applications

GNU GPL v 3.0

The project is hosted on Github: ahcache

Download

Requirements

You can use this class nearly anywhere on each hoster in the world. The requirements are the most simple you can imagine:

  • PHP 5 or 7
  • a writeable directory; [webroot]/~cache/ by default







Copyright © 2009-2018 Axel Hahn
project page: GitHub (en)
Axels Webseite (de)
results will be here