2017 © Pedro Peláez
 

library super-cache

Simple PHP cache mechanism which is 500X Faster Caching than Redis/Memcache/APC in PHP & HHVM

image

smart-php/super-cache

Simple PHP cache mechanism which is 500X Faster Caching than Redis/Memcache/APC in PHP & HHVM

  • Wednesday, July 18, 2018
  • by shabeer-ali-m
  • Repository
  • 1 Watchers
  • 1 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

php-super-cache

Simple PHP cache mechanism which provides 200X Faster Caching than other PHP cache mechanisms like Redis/Memcache/APC in PHP & HHVM. SuperCache uses the normal file system to store values. This method is faster than Redis/Memcache because all those serialize and unserialize objects., (*1)

GitHub tag, (*2)

Installation

Via Composer ``` bash composer require smart-php/super-cache, (*3)


### Basic Usage ```php ')->set(''); sCache::cache('myKey')->set('Key_value'); //Retrieving cache value with a key echo sCache::cache('myKey')->get(); ?>

Cache Folder

By default the cache will save in the tmp folder. Please make sure that the tmp folder has write access. You can set a custom folder for the cache:, (*4)

sCache::setPath('youfolder/tempfolder/');

or, (*5)

define('SuperCache_PATH','youfolder/tempfolder/');

Advanced Options

Locking

Lock your data to readonly so that the data won't be overwritten., (*6)

sCache::cache('myKey')->set('my_value')->lock();
//setting new value
sCache::cache('myKey')->set('new_value');
echo sCache::cache('myKey')->get(); //output : my_value
//unlocking
sCache::cache('myKey')->unlock()->set('new_value');
echo sCache::cache('myKey')->get(); //output : new_value
Options
//options
sCache::cache('myKey')->set('my_value')->options([
    'expiry'    =>  time()+600, //time to expire
    'lock'      =>  true    //alternative method to lock or unlock
    'custom'    =>  'your customer attribute value'
]);

//isValid (To check for a valid key or to check whether it has expired or not)
sCache::cache('myKey')->isValid(); //true or false

//To get all option values
print_r(sCache::cache('myKey')->getOptions()); //array

//destroy
sCache::cache('myKey')->destroy();

//clearAll (Clear all cache values)
sCache::cache('myKey')->clearAll();

Cache Your Class

You can cache any class to super cache. To bind data you need to use the trait class State by adding use State, or you can do it via your custom set_state., (*7)

use SuperCache\SuperCache as sCache;
use SuperCache\State as State;

sCache::setPath('youCacheLocation');

Class MyClass 
{
    /**
     * This trait class will bind data from cache to your class
     */
    use State;

    private $firstName;

    private $lastName;

    public function setName($firstName, $lastName)
    {
        $this->firstName = $firstName;
        $this->lastName = $lastName;
    }

    public function getName()
    {
        return $this->firstName . " ". $this->lastName;
    }
}

// Creating Object of your class
$myObject = new MyClass;
$myObject->setName("John", "Doe");

// Saving your object in SuperCache
sCache::cache('myObject')->set($myObject);

// Retrieving your object from Cache 
$cacheObject = sCache::cache('myObject')->get();
echo $myObject->getName();

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

18/07 2018

0.0.3

0.0.3.0

Simple PHP cache mechanism which is 500X Faster Caching than Redis/Memcache/APC in PHP & HHVM

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Shabeer Ali M

cache php lightweight caching powerful php-cache php-super-cache super-cache

18/07 2018

dev-master

9999999-dev

Simple PHP cache mechanism which is 500X Faster Caching than Redis/Memcache/APC in PHP & HHVM

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Shabeer Ali M

cache php lightweight caching powerful php-cache php-super-cache super-cache

10/06 2018

0.0.2

0.0.2.0

Simple PHP cache mechanism which is 500X Faster Caching than Redis/Memcache/APC in PHP & HHVM

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Shabeer Ali M

cache php lightweight caching powerful php-cache php-super-cache super-cache