2017 © Pedro Peláez
 

library memoizer

Simple PHP Memoizer class

image

ganglio/memoizer

Simple PHP Memoizer class

  • Wednesday, March 2, 2016
  • by ganglio
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Memoizer

Simple PHP Memoizer class, (*1)

Latest Stable Version Build Status codecov.io Code Climate Scrutinizer Code Quality License, (*2)

The class allow to encapsulate any callable so that, during the first call (with a given set of arguments), the callable is executed and the return values are stored. At every successive call (with the same set of arguments) the stored value is used instead of invoking the callable again., (*3)

Examples

This is a dumb example with a time variant call just to demonstate the way the memoized function works. If your callable has that kind of behaviour memoizing it is probably not a good idea :D, (*4)

$myFunc = function ($a) {
    return $a * mt_rand();
}

$myMemoizedFunc = new Memoizer($myFunc);

echo "Returns: " . $myMemoizedFunc(3) . "\n";
echo "Returns the same value: " . $myMemoizedFunc(3) . "\n";

A time consuming callable can be made more efficient storing the return value for later invokation., (*5)

$mySlowFunc = function ($a) {
    sleep(5);
    return $a * mt_rand();
}

$myMemoizedSlowFunc = new Memoizer($mySlowFunc);

$st = time();
echo "Returns: " . $myMemoizedSlowFunc(3) . " in: " . (time() - $st);

$st = time();
echo "Returns the same value: " . $myMemoizedSlowFunc(3) . " in basically 0 time: " . (time() - $st);

The Versions

02/03 2016

dev-master

9999999-dev http://www.github.com/ganglio/Memoizer

Simple PHP Memoizer class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Roberto Torella

memoize

02/03 2016

v1.0.4.2

1.0.4.2 http://www.github.com/ganglio/Memoizer

Simple PHP Memoizer class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Roberto Torella

memoize

29/02 2016

v1.0.4.1

1.0.4.1 http://www.github.com/ganglio/Memoizer

Simple PHP Memoizer class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Roberto Torella

memoize

29/02 2016

v1.0.4

1.0.4.0 http://www.github.com/ganglio/Memoizer

Simple PHP Memoizer class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Roberto Torella

memoize

27/02 2016

v1.0.3

1.0.3.0 http://www.github.com/ganglio/Memoizer

Simple PHP Memoizer class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Roberto Torella

memoize

27/02 2016

v1.0.2

1.0.2.0 http://www.github.com/ganglio/Memoizer

Simple PHP Memoizer class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Roberto Torella

memoize

27/02 2016

v1.0.1

1.0.1.0 http://www.github.com/ganglio/Memoizer

Simple PHP Memoizer class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Roberto Torella

memoize

27/02 2016

v1.0.0

1.0.0.0 http://www.github.com/ganglio/Memoizer

Simple PHP Memoizer class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Roberto Torella

memoize