-
-
Notifications
You must be signed in to change notification settings - Fork 452
Home
Sebastian Zartner edited this page Feb 15, 2016
·
38 revisions
More information at http://www.phpfastcache.com One Class uses for All Cache. You don't need to rewrite your code many times again. Supported: Redis, Files, MemCache, MemCached, APC, WinCache, X-Cache, Cookie, PDO with SQLite
Reduce Database Calls
If your website has 10,000 visitors, your dynamic page has to send 10,000 times the same query to the database on every page load. With phpFastCache, your page only sends one query to the DB and uses the cache to serve the other 9,999 visitors.
<?php
// In your config file
include("phpfastcache/phpfastcache.php");
phpFastCache::setup("storage","auto");
// phpFastCache support "redis", "cookie", "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();
// $cache = phpFastCache("redis");
// 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
?>
❓ Finally, if you need help, always check out the inevitable README.md