crodas / remember
Remember computations you did before (file cache)
Installs: 9 752
Dependents: 5
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- crodas/file-util: ^0.2.2
Requires (Dev)
- crodas/phpunit-compat: ^1.7
- crodas/simple-view-engine: ^0.1.37
- phpdocumentor/phpdocumentor: ^2.9
README
Easiest way to remember things across requests in PHP.
Motivation
I love generating code and I needed a way of rebuilding only if something changed.
How it works
use Remember\Remember;
$function = Remember::wrap('name', function(Array $args, Array $files) {
// do some that is expensive
return $result;
});
// It will calculate once and cache the result
// until __FILE__ changes.
$result = $function([__FILE__, 'foobar']);
Low level API
use Remember\Remember;
$ns = Remember::ns('foobar');
$result = $ns->get([__FILE__], $isValid);
if (!$isValid) {
// do something
$result = ...;
$ns->store([__FILE__], $result);
}