@@ -691,40 +691,28 @@ <h2>PHP Caching Class For Database</h2>
691
691
< pre class ="prettyprint php ">
692
692
<?php
693
693
// In your config file
694
- // include("phpFastCache/phpFastCache.php"); or use "Composer" Vendor / Autoload
695
- // phpFastCache support "ssdb", "mongodb", "redis", "cookie", "apc", "memcache",
696
- // "memcached", "wincache" ,"files", "sqlite" and "xcache"
694
+ // include("phpFastCache/phpFastCache.php"); or use "Composer" / Autoload
697
695
698
696
use phpFastCache\CacheManager;
699
697
700
698
$config = array(
701
- "storage" => "files",
699
+ "storage" => "files", // memcached, redis, ssdb, ..etc
702
700
"path" => "/your_cache_path/dir/",
703
701
);
704
-
705
702
CacheManager::setup($config); // look at folder "Examples" for more setup & config
706
- CacheManager::CachingMethod("phpfastcache"); // use "normal" as traditional
707
-
708
- // You don't need to change your code when you change your caching system,
709
- $cache = CacheManager::getInstance();
710
- // $cache = CacheManager::Files();
711
- // $cache = CacheManager::Memcached(); < -- ::Reids() ::Predis() ::ssdb() ..etc
712
- // $cache = CacheManager::getInstance( "redis", $config);
713
703
714
704
// In your Class, Functions, PHP Pages
715
- // try to get from Cache first. product_page = YOUR Identity Keyword
716
- $products = $cache-> get("product_page");
717
- // Lazy? $products = CacheManager::get("keyword");
705
+ // First try to get from Cache first. product_page = YOUR Identity Keyword
706
+ $products = CacheManager::get("keyword");
718
707
719
708
if(is_null($products)) {
720
709
$products = YOUR DB QUERIES || GET_PRODUCTS_FUNCTION;
721
710
// set products in to cache in 600 seconds = 10 minutes and 0 = never expired
722
- $cache- > set("product_page", $products,600);
723
- // CacheManager::set() work the same too
711
+ CacheManager:: set("product_page", $products,600);
712
+ // In next 600 seconds, phpFastCache will take care your heavy traffic
724
713
}
725
714
726
- // Output Your Contents $products HERE
727
- // LOOP | echo $products
715
+ // LOOP | Output Your $products
728
716
</ pre >
729
717
</ p >
730
718
< br > < br >
@@ -741,6 +729,11 @@ <h2>Powerful PHP Caching Class</h2><p class="inline">: You are using Bing API, G
741
729
use phpFastCache\CacheManager;
742
730
743
731
$cache = CacheManager::Memcached();
732
+ // Yo? Look at examples Folder.
733
+ // $cache = CacheManager::getInstance();
734
+ // $cache = CacheManager::getInstance("redis", $setup);
735
+ // $cache = CacheManager::Files($setup);
736
+ // $cache = CacheManager::Redis();
744
737
745
738
// try to get from Cache first.
746
739
$results = $cache-> get("identity_keyword")
0 commit comments