PHP cache library phpFastCache

Source: Internet
Author: User
Tags apc
PhpFastCache is an open-source PHP cache library that provides only one simple PHP file and can be easily integrated into existing projects. It supports multiple caching methods, including apc, memcache, memcached, wincache, files, pdoandmpdo. You can use a simple API to define the cache validity period. Reduce database queries? PhpInyour

PhpFastCache is an open-source PHP cache library that provides only one simple PHP file and can be easily integrated into existing projects. It supports multiple caching methods, including apc, memcache, memcached, wincache, files, pdo and mpdo. You can use a simple API to define the cache validity period. Reduce database queries? Php // In your

PhpFastCache is an open source PHPCacheLibrary, only provides a simple PHP file, which can be easily integrated into existing projects and supports multipleCacheMethods, including apc, memcache, memcached, wincache, files, pdo and mpdo. You can use simple APIs to defineCache.

Reduce database queries

 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

Improve cURL and API call Performance

 get("identity_keyword")    if($results == null) {        $results = cURL->get("http://www.youtube.com/api/json/url/keyword/page");        // Write to Cache Save API Calls next time        $cache->set("identity_keyword", $results, 3600*24);    }    foreach($results as $video) {        // Output Your Contents HERE    }


Full pageCache

 get($keyword_webpage);    if($html == null) {        ob_start();        /*            ALL OF YOUR CODE GO HERE            RENDER YOUR PAGE, DB QUERY, WHATEVER        */        // GET HTML WEBPAGE        $html = ob_get_contents();        // Save to Cache 30 minutes        __c("files")->set($keyword_webpage,$html, 1800);    }    echo $html;


PendantCache

 widget_1;    if($html == null) {        $html = Render Your Page || Widget || "Hello World";        // Save to Cache 30 minutes        $cache->widget_1 = array($html, 1800);    }    echo or return your $html;


MultipleCache

 option("server", $server);    $cache3 = new phpFastCache("apc");    // How to Write?    $cache1->set("keyword1", "string|number|array|object", 300);    $cache2->keyword2 = array("something here", 600);    __c()->keyword3 = array("array|object", 3600*24);    // How to Read?    $data = $cache1->get("keyword1");    $data = $cache2->keyword2;    $data = __c()->keyword3;    $data = __c()->get("keyword4");    // Free to Travel between any caching methods    $cache1 = phpFastCache("files");    $cache1->set("keyword1", $value, $time);    $cache1->memcache->set("keyword1", $value, $time);    $cache1->apc->set("whatever", $value, 300);    $cache2 = __c("apc");    $cache2->keyword1 = array("so cool", 300);    $cache2->files->keyword1 = array("Oh yeah!", 600);    $data = __c("memcache")->get("keyword1");    $data = __c("files")->get("keyword2");    $data = __c()->keyword3;    // Multiple ? No Problem    $list = $cache1->getMulti(array("key1","key2","key3"));    $cache2->setMulti(array("key1","value1", 300),                      array("key2","value2", 600),                      array("key3","value3", 1800),                      );    $list = $cache1->apc->getMulti(array("key1","key2","key3"));    __c()->memcache->getMulti(array("a","b","c"));    // want more? Check out document in source code

The demo is from the official website.


Official website address: http://www.phpfastcache.com/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.