dev-master
9999999-dev https://github.com/malenkiki/apcSimple wrapper for some APC features.
MIT
The Requires
- php >=5.3.0
- ext-apc *
by Michel Petit
cache apc oop
Wallogit.com
2017 © Pedro Peláez
Simple wrapper for some APC features.
Small wrapper of some apc features., (*1)
You can clone this repository or use composer, because APC is available on Packagist!, (*2)
{
"require": {
"malenki/apc": "dev-master",
}
}
While you instanciate an object of this class, you must give at least one argument to set the key name:, (*3)
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected'); // TTL = 0 by default here
You can give second argument, an positive integer, for the time to live duration in seconds:, (*4)
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 60); // Given TTL is one minute
Very easy, you have the choice by using set() method or the magick setter value:, (*5)
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
$apc->set('foo');
//or
$apc->value = 'foo';
As you have seen into previous case, you can use for getting value two ways: get() method or magic getter value., (*6)
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
var_dump($apc->get());
//or
var_dump($apc->value);
You may print content into string context too:, (*7)
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
$apc->value = 'foo';
echo $apc; // will print "foo"
If the value is not a scalar, print_r() function is used., (*8)
You can force removing value from APC cache using delete() method or magic unset():, (*9)
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
$apc->set('foo');
$apc->delete();
// or
unset($apc->value);
You can test if a value exists before doing something with it. You have to call exists() method or magic isset():, (*10)
use \Malenki\Apc;
$apc = new Apc('key_id_you_have_selected', 3600);
// using method
if(!$apc->exists())
{
$apc->value = 'foo';
}
// or magic isset()
if(!isset($apc->value))
{
$apc->value = 'foo';
}
You can clean all or just some part like user or opcode:, (*11)
use \Malenki\Apc;
Apc::clean(); // clean all
// or
Apc::clean('user'); // clean user cache type
// or
Apc::clean('opcode'); // clean opcode cache type
Simple wrapper for some APC features.
MIT
cache apc oop