forked from PHPSocialNetwork/phpfastcache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
33 lines (22 loc) · 726 Bytes
/
example.php
File metadata and controls
33 lines (22 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/*
* Welcome to Learn Lesson
* This is very Simple PHP Code of Caching
*/
// Require Library
require_once("phpfastcache.php");
// simple Caching with:
$cache = phpFastCache();
// Try to get $products from Caching First
// 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);
echo " --> NO CACHE ---> DB | Func | API RUN FIRST TIME ---> ";
} else {
echo " --> USE CACHE --> SERV 10,000+ Visitors FROM CACHE ---> ";
}
// use your products here or return it;
echo $products;