The PHP high-performance object caching system ever.

phpFastCache is a high-performance, distributed object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

phpFastCache dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful

Just try it and your website will faster like 1,000 times

Heavy Visitor Rain

Your PHP is sending 10,000 queries extractly the same to Database. Let phpFastCache reduce it to 1 query and serve your 10,000 visitors. You need A

PHP Cache Class

Supported

APC

,

XCache

,

MemCache

,

MemCached

,

WinCache

, Files

You will never have to rewrite your

PHP caching class

again when you change your servers

Dude, It's awesome! My websites are running smooth with any shared hosting, No VPS upgrade needed!

P. Tran, Alilang Fashion
Document & API

A Simple PHP Caching Class

From Apr 28 2013, phpFastCache is available in GitHub, and it also support more objects type caching.

API Functions are available below.

I don't need to upgrade to Dedicated, phpFastCache saved my little VPS

J. Nguyen, EDM Inc
  • Q. What are the requirements for using phpFastCache?
    +
  • Q. How to Install it?
    +
  • X. API Methods
    +
  • X. Learn Basic
    +
  • X. Setup & Configuration
    +
  • X. All Functions
    +
  • X. Shortcut
    +
  • X. Traveling
    +
  • X. Master
    +
  • Q. Why use phpFastCache as Your Caching Method?
    +
Reduce Database Calls

PHP Caching Class For Database

: Your website have 10,000 visitors who are online, and your dynamic page have to send 10,000 same queries to database on every page load. With phpFastCache, your page only send 1 query to DB, and use the cache to serve 9,999 other visitors.


<?php
    // In your config file
    include("phpfastcache/phpfastcache.php");
    phpFastCache::setup("storage","auto");

    // phpFastCache support "apc", "memcache", "memcached", "wincache" ,"files", "sqlite" and "xcache"
    // You don't need to change your code when you change your caching system. Or simple keep it auto
    $cache = phpFastCache();

    // In your Class, Functions, PHP Pages
    // try to get from Cache first. product_page = YOUR Identity Keyword
    $products = $cache->get("product_page");

    if($products == null) {
        $products = YOUR DB QUERIES || GET_PRODUCTS_FUNCTION;
        // set products in to cache in 600 seconds = 10 minutes
        $cache->set("product_page", $products,600);
    }

    // Output Your Contents $products HERE
?>



Improve cURL & API Calls

Powerful PHP Caching Class

: You are using Bing API, Google API or cURL and your API transactions are limited? phpFastCache can save your Server CPU & API Transactions. You can use phpFastCache to do it easily.


<?php
    include("phpfastcache/phpfastcache.php");

    $cache = phpFastCache("memcached");

    // try to get from Cache first.
    $results = $cache->get("identity_keyword")

    if($results == null) {
        $results = cURL->get("http://www.youtube.com/api/json/url/keyword/page");
        // Write to Cache Save API Calls next time
        $cache->set("identity_keyword", $results, 3600*24);
    }

    foreach($results as $video) {
        // Output Your Contents HERE
    }
?>



Rendering Widget & Page

Simple PHP Files Caching Class

: phpFastCache help you speed up your website thounsand times by caching your page and widget rendering.


<?php
    // use Files Cache for Whole Page / Widget
    $cache = phpFastCache("files");

    $html = $cache->widget_1;

    if($html == null) {
        $html = Render Your Page || Widget || "Hello World";
        // Save to Cache 30 minutes
        $cache->widget_1 = array($html, 1800);
    }

    echo or return your $html;
?>



Caching Whole Webpage

PHP Cache whole web page

: You can use phpFastCache to cache the whole webpage easy too. This is simple example, but in real code, you should split it to 2 files: cache_start.php and cache_end.php. The cache_start.php will store the beginning code until ob_start(); and the cache_end.php will start from GET HTML WEBPAGE. Then, your index.php will include cache_start.php on beginning and cache_end.php at the end of file.


<?php
    // use Files Cache for Whole Page / Widget

    // keyword = Webpage_URL
    $keyword_webpage = md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING']);
    $html = __c("files")->get($keyword_webpage);

    if($html == null) {
        ob_start();
        /*
            ALL OF YOUR CODE GO HERE
            RENDER YOUR PAGE, DB QUERY, WHATEVER
        */

        // GET HTML WEBPAGE
        $html = ob_get_contents();
        // Save to Cache 30 minutes
        __c("files")->set($keyword_webpage,$html, 1800);
    }

    echo $html;
?>



Enable Multi Caching Method

Example with Files, PDO, APC, WinCache, XCache, MemCache and MemCached Caching

: phpFastCache will set up multiple caching files, maximum 50MB per file, and you can SET/Get from APC, MemCache .. etc. It's good for caching cURL Data and API call results. You can mix multiple methods with phpFastCache. For example, mix files caches with APC, or PDO and memcached.


<?php
    // in your config files
    include("phpfastcache/phpfastcache.php");
    // auto | memcache | files ...etc. Will be default for $cache = __c();
    phpFastCache::$storage = "auto";

    $cache1 = phpFastCache();

    $cache2 = __c("memcache");
    $server = array(array("127.0.0.1",11211,100), array("128.5.1.3",11215,80));
    $cache2->option("server", $server);

    $cache3 = new phpFastCache("apc");

    // How to Write?
    $cache1->set("keyword1", "string|number|array|object", 300);
    $cache2->keyword2 = array("something here", 600);
    __c()->keyword3 = array("array|object", 3600*24);

    // How to Read?
    $data = $cache1->get("keyword1");
    $data = $cache2->keyword2;
    $data = __c()->keyword3;
    $data = __c()->get("keyword4");

    // Free to Travel between any caching methods

    $cache1 = phpFastCache("files");
    $cache1->set("keyword1", $value, $time);
    $cache1->memcache->set("keyword1", $value, $time);
    $cache1->apc->set("whatever", $value, 300);

    $cache2 = __c("apc");
    $cache2->keyword1 = array("so cool", 300);
    $cache2->files->keyword1 = array("Oh yeah!", 600);

    $data = __c("memcache")->get("keyword1");
    $data = __c("files")->get("keyword2");
    $data = __c()->keyword3;

    // Multiple ? No Problem

    $list = $cache1->getMulti(array("key1","key2","key3"));
    $cache2->setMulti(array("key1","value1", 300),
                      array("key2","value2", 600),
                      array("key3","value3", 1800),
                      );

    $list = $cache1->apc->getMulti(array("key1","key2","key3"));
    __c()->memcache->getMulti(array("a","b","c"));

    // want more? Check out document in source code


?>



Want more? Check our Document!

phpFastCache is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches.

Updates
Version 2.0 & Revision 621
Released on Aug 4th, 2013
  • New New Methods
  • New New Classes & Improved Everything
Revision 618
Released on Jun 26th, 2013
  • New .htaccess Security for Cache Folder
  • New Mod-PHP / Apache2Handler will use TMP Dir as default
Version 1.3.0.1
Released on May 11th, 2013
  • New X-Cache Supported
  • Fix phpFastCache::$files_cleanup_after = 1; // hour
Version 1.3
Released on May 6th, 2013
  • New APC, MemCache, MemCached, WinCache, Files Supported
  • New Added $storage = "auto"
  • New Added exists, setMulti, getMulti, deleteMulti
  • Fix Removed Cache.0777 files
  • Fix Improve Security with $securityKey = "keyword"
  • Fix Removed PDO Required
Version 1.2
Released on April 30th, 2013
  • New cURL Supported
  • Fix resetAll() & fixes
  • New Added auto vacuum for every 48 hours
  • fix More objects supported
Version 1.1
Released on November 10th, 2011
  • New Full PHP5 compatibility
  • Fix Skip items & fixes
  • New Added In Memory Caching (Beta)
  • fix $PATH
Version 1.0
Released on January 1st, 2011
  • New Initial release for phpFastCache
Contact

If you are looking for

Simple PHP Files Cache

,

Fastest PHP Caching Class

, and

Easiest Integrating Multiple Caching Methods

, then You should pick

PHP Fast Cache


For general questions, bug reports or press inquires please fill out the form below.

Oops! Please correct the highlighted fields...

Thanks! I'll get back to you shortly.