
Here’s how we “set” a value in the cache: function cache_set($key, $val) By storing PHP objects in file cache memory across requests, we can avoid serialization completely! The reason this method is faster than Redis, Memcache, APC, and other PHP caching solutions is the fact that all those solutions must serialize and unserialize objects, generally using PHP’s serialize or json_encode functions. The method still “works” in PHP < 7, it just isn’t fast.

HHVM has supported this technique for a few years, but PHP only recently started supporting it with the launch of PHP 7. The core of the technique is leveraging the PHP engine’s in-memory file caching (opcache) to cache application data in addition to code. In this post, I’ll tell you how we’ve implemented “PHP file caching” in our application logic at Graphiq, resulting in crazy-fast cache reads. 500X Faster Caching than Redis/Memcache/APC in PHP & HHVM
