Download the PHP package benjamindean/one-line-apc without Composer
On this page you can find all versions of the php package benjamindean/one-line-apc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download benjamindean/one-line-apc
More information about benjamindean/one-line-apc
Files in benjamindean/one-line-apc
Package one-line-apc
Short Description Dead simple wrapper class for APC and APCu which capable of setting and getting cached data in one line.
License MIT
Homepage https://github.com/benjamindean/one-line-apc
Informations about the package one-line-apc
OneLineAPC
Dead simple wrapper class for APC and APCu which capable of setting and getting cached data from a callback or a variable in one single line.
Requirements
- PHP 5.3 or later
php-apc
extension installed
Installation
Install with Composer:
Usage
By default, this class uses APC. To use APCu just pass it while instantiating the class:
Default TTL is 79200 (22 hours). To change it, call setTtl
method:
OR, specify it individually as a last argument to setCache
or cached
methods:
Cached
The main and the most important method (the reason I created this class) is called cached
:
functionName
is the name of some function in your code which returns the data that needs to be cached. Any variable, integer or string will work too.
You can also pass function arguments as a third argument here.
In case your function is within some class, pass it as an array of Object and a function name:
You can find out more about callbacks here.
Examples
Class method
Function
Variable
Notes
If apc
or apcu
is not loaded, this class will generate "Notice", instead of "Fatal Error".