Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions example.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

/*
/**
* Welcome to Learn Lesson
* This is very Simple PHP Code of Caching
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
*/

// Require Library
Expand All @@ -15,15 +16,15 @@
// product_page is "identity keyword";
$products = $cache->get("product_page");

if($products == null) {
$products = "DB QUERIES | FUNCTION_GET_PRODUCTS | ARRAY | STRING | OBJECTS";
// Write products to Cache in 10 minutes with same keyword
$cache->set("product_page",$products , 600);
if ($products == null) {
$products = "DB QUERIES | FUNCTION_GET_PRODUCTS | ARRAY | STRING | OBJECTS";
// Write products to Cache in 10 minutes with same keyword
$cache->set("product_page", $products, 600);

echo " --> NO CACHE ---> DB | Func | API RUN FIRST TIME ---> ";
echo " --> NO CACHE ---> DB | Func | API RUN FIRST TIME ---> ";

} else {
echo " --> USE CACHE --> SERV 10,000+ Visitors FROM CACHE ---> ";
echo " --> USE CACHE --> SERV 10,000+ Visitors FROM CACHE ---> ";
}

// use your products here or return it;
Expand Down
24 changes: 12 additions & 12 deletions example2.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

/*
/**
* Welcome to Learn Lesson
* This is very Simple PHP Code of Caching
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
*/

// Require Library
Expand All @@ -11,31 +12,30 @@
// simple Caching with:
$cache = phpFastCache("redis");

if($cache->fallback === true) {
echo " USE BACK UP DRIVER = ".phpFastCache::$config['fallback']." <br>";
if ($cache->fallback === true) {
echo " USE BACK UP DRIVER = " . phpFastCache::$config[ 'fallback' ] . " <br>";
} else {
echo ' DRIVER IS GOOD <br>';
echo ' DRIVER IS GOOD <br>';
}



// Try to get $products from Caching First
// product_page is "identity keyword";
$products = $cache->get("product_page2");

if($products == null) {
$products = "DB QUERIES | FUNCTION_GET_PRODUCTS | ARRAY | STRING | OBJECTS";
// Write products to Cache in 10 minutes with same keyword
$cache->set("product_page2",$products , 2);
if ($products == null) {
$products = "DB QUERIES | FUNCTION_GET_PRODUCTS | ARRAY | STRING | OBJECTS";
// Write products to Cache in 10 minutes with same keyword
$cache->set("product_page2", $products, 2);

echo " --> NO CACHE ---> DB | Func | API RUN FIRST TIME ---> ";
echo " --> NO CACHE ---> DB | Func | API RUN FIRST TIME ---> ";

} else {
echo " --> USE CACHE --> SERV 10,000+ Visitors FROM CACHE ---> ";
echo " --> USE CACHE --> SERV 10,000+ Visitors FROM CACHE ---> ";
}

// use your products here or return it;
echo "Products = ".$products;
echo "Products = " . $products;



Loading