How to use phpfastcache to Cache Data to Files


Most of the PHP Frameworks I worked on or experimented with have their own ways of caching things to reduce calls to other systems (e.g., RDBMS) or interfaces to plug in third-party caching libraries. But what if you had an application that did not use any known framework? There are simple-to-use caching libraries that can be easily integrated into your existing project.

Software Requirements

  • Windows 7 Professional SP1
  • PHP 5.5.9 / Zend Engine v2.5.0
  • NetBeans IDE 8.0.1
  • ApacheFriends XAMPP Version 1.8.3
    • ​Apache/2.4.7 (Win32) / Open SSL/1.0.1e

Download phpfastcache

You may download it directly from https://github.com/Turreta/phpfastcache. This is a fork of https://github.com/khoaofgod/phpfastcache. Unzip the file and copy the phpfastcache directory into your application in Apache web server.


For instance, phpfastcachetest is an application for this post.


The Codes

The contents of mytest.php are as follow:

Test It

Note that the test is via a web browser. Simply use the URL below:

Upon display, it displays:

On subsequent page display:

The data is cached to a directory in the file system.



Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert