1. Go to this page and download the library: Download mz/php-proxy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mz / php-proxy example snippets
use MZ\Proxy\Shortcuts;
// object proxy
$object = new MyComplexClass();
$proxy = Shortcuts\wrapWithMemoryProxy($object, 5); // 5 seconds timeout (default = 0 - infinite)
$proxy->foo(); // executes foo, stores result in cache
$proxy->foo(); // returns cached result, real foo method is not executed
$proxy->bar(); // works here too
$property = $proxy->my_property // exactly as $object->my_property
$proxy->my_property = 123; // exactly as $object->my_property = 123
// set cached methods
$proxy->proxySetMethods(array('foo', 'bar'));
$proxy->foo(); // cached
$proxy->bar(); // cached
$proxy->baz(); // not cached
$proxy->proxySetMethods(null); // all methods cached fro this point (default)
$callable = function() {
// some time intensive code...
};
$proxy = Shortcuts\wrapWithMemoryProxy($callable);
$result = $proxy(); // executes function
$result = $proxy(); // returns cached result
use MZ\Proxy\Shortcuts;
$object = new MyComplexClass();
$memcache = new \Memcache();
$memcache->addServer('localhost', 11211);
$proxy = Shortcuts\wrapWithMemcacheProxy(
$object,
'memcache_prefix',
$memcache
);
$result = $proxy->foo(); // executes foo
$result = $proxy->foo(); // returns cached result, real foo method is not executed
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.