Giter VIP home page Giter VIP logo

skhani / phpfastcache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phpsocialnetwork/phpfastcache

1.0 2.0 0.0 3.43 MB

The PHP high-performance object caching system ever. phpFastCache is a high-performance, distributed object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. phpFastCache dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful

Home Page: http://www.phpfastcache.com

PHP 100.00%

phpfastcache's Introduction

Simple Yet Powerful PHP Caching Class

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: Files, MemCache, MemCached, APC, WinCache, X-Cache, PDO with SQLite


Reduce Database Calls

Your website have 10,000 visitors who are online, and your dynamic page have to send 10,000 same queries to database on every page load. With phpFastCache, your page only send 1 query to DB, and use the cache to serve 9,999 other visitors.

<?php
/*
 * Welcome to Learn Lesson
 * This is very Simple PHP Code of Caching
 */

// Require Library
// Keep it Auto or setup it as "files","sqlite","wincache" ,"apc","memcache","memcached", "xcache"
require_once("../phpfastcache/phpfastcache.php");
phpFastCache::setup("storage","auto");

// 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);
}

// use your products here or return it;
echo $products;

<?php

/*
 * List of function and example
 */
require_once("../phpfastcache/phpfastcache.php");
$cache = phpFastCache();

// Write into cache
$cache->set("keyword", "data | array | object", 300);

// Read from Cache | return null or data
$data = $cache->get("keyword");
echo $data;

// Read object information | value | time from cache
$object = $cache->getInfo("keyword");
print_r($object);

// Delete from cache
$cache->delete("keyword");

// Clean up all cache
$cache->clean();

// Stats
$array = $cache->stats();
print_r($array);

// Increase and Decrease Cache value - Return  true | false
$cache->increment("keyword", 1);
$cache->decrement("keyword", 1);

// Extend expiring time - Return true | false;
$cache->touch("keyword", 1000);

// Check Existing or not - Return true | false;
$cache->isExisting("keyword");

// Get & Set Multiple Items
// Same as above, but input is array();

$list = $cache->getMulti(array("key1","key2","key3"));

$list = $cache->getInfoMulti(array("key1","key2","key3"));

$cache->setMulti(array("key1","value1", 300),
    array("key2","value2", 600),
    array("key3","value3", 1800));

$cache->deleteMulti(array("key1","key2","key3"));

$cache->isExistingMulti(array("key1","key2","key3"));

$cache->touchMulti(array(
                    array("key", 300),
                    array("key2", 400),
                   ));

$cache->incrementMulti(array(
                        array("key", 1),
                        array("key2", 2),
                    ));

$cache->decrementMulti(array(
                        array("key", 1),
                        array("key2", 2),
                    ));



phpfastcache's People

Contributors

khoaofgod avatar saiful avatar lemark0 avatar nigrosimone avatar kantholy avatar olamedia avatar sigjlr avatar

Stargazers

Shahin Khani avatar

Watchers

James Cloos avatar Shahin Khani avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.