kdaviesnz/memoization

Wrapper for Ed Mann's memoize function

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/kdaviesnz/memoization

dev-master 2018-06-06 20:07 UTC

This package is not auto-updated.

Last update: 2025-10-19 14:10:36 UTC


README

Wrapper for Ed Mann's memoize function

see https://eddmann.com/posts/implementing-and-using-memoization-in-php/

Install

Via Composer

$ composer require kdaviesnz/Memoization

Usage

        $sleepz = \kdaviesnz\memoization\Memoization::memoize(function($time){
            sleep( $time );
            return true;
        });

        $firstTestStart = \microtime(true);
        $sleepz(1);
        $firstTestEnd = \microtime(true);

        $secondTestStart = \microtime(true);
        $sleepz(1);
        $secondTestEnd = \microtime(true);

        $firstTestTime = $firstTestEnd - $firstTestStart;
        $secondTestTime = $secondTestEnd - $secondTestStart;

        echo "First test took $firstTestTime ms\n";
        echo "Second test took $secondTestTime ms\n";

Change log

Please see CHANGELOG.md for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING.md and CODE_OF_CONDUCT.md for details.

Security

If you discover any security related issues, please email kdaviesnz@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see LICENSE.md for more information.

Memoization