1. Go to this page and download the library: Download tonybogdanov/memoize 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/ */
tonybogdanov / memoize example snippets
class ClassUsingCaching {
use \TonyBogdanov\Memoize\Traits\MemoizeTrait;
public function getObjectLevelCachedThing() {
return $this->memoize( __METHOD__, function () {
return 'thing'; // heavy code that needs to run only once per object instance.
} );
}
}
$object->unmemoize( 'key' );
$object->isMemoized( 'key' );
class ClassUsingCaching {
use \TonyBogdanov\Memoize\Traits\MemoizeTrait;
public static function getClassLevelCachedThing() {
return static::memoizeStatic( __METHOD__, function () {
return 'thing'; // heavy code that needs to run only once per class.
} );
}
}