PHPackages                             ksamborski/apcu-memo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ksamborski/apcu-memo

ActiveLibrary

ksamborski/apcu-memo
====================

0.4(9y ago)02.6kMITPHPPHP &gt;=7.0.0

Since Oct 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ksamborski/apcumemo)[ Packagist](https://packagist.org/packages/ksamborski/apcu-memo)[ RSS](/packages/ksamborski-apcu-memo/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

\#apcumemo PHP library for memoization function results based on it's arguments.

Requirements
------------

[](#requirements)

You need to have acpu extension installed for php &gt;= 7.0.0

Installation
------------

[](#installation)

```
composer require ksamborski/apcu-memo
```

Basic usage
-----------

[](#basic-usage)

Functional paradigm teaches us that pure functions are the way to go. They provide two main features:

- because their result depends only on their arguments they can be easly tested (you don't need any mocks or stubs)
- because they have no side effects they can be easly cached

Consider this example:

```
use APCuMemo\APCuMemo;

function sumrange($a, $b)
{
    return APCuMemo::memoize(
        function(...$_) use ($a, $b) {
            return array_reduce(range($a, $b), function ($product, $item) { return $product + $item; }, 1);
        },
        [ 'ttl' => 5 ],
        "sumrange",
        $a,
        $b
    );
}

$start = microtime(true);
echo sumrange((int) $_GET['a'], (int) $_GET['b']);
$elapsed = microtime(true) - $start;
echo " " . ($elapsed * 1000) . " ms";
```

We have a simple function that sums integers from $a to $b. It can take some time but when we compute it for the first time then we can cache it. Notice the 'ttl' parameter. It is set to 5 seconds and means that if nobody asks us for the same range within 5 seconds it will forget the result. But every request for cached value will reset the ttl. That way we can have only mostly used values in cache.

Let's see it in action. For $a = 1 and $b = 1831233 it will return something like:

```
1676708065762 283.94412994385 ms
```

And the followed requests will return:

```
1676708065762 0.030040740966797 ms
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

3493d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e0485f4ee97b97d827c6605bf753adce47ab827c875f07bf373545a38ad86de?d=identicon)[ksamborski](/maintainers/ksamborski)

---

Top Contributors

[![ksamborski](https://avatars.githubusercontent.com/u/14052422?v=4)](https://github.com/ksamborski "ksamborski (1 commits)")

### Embed Badge

![Health badge](/badges/ksamborski-apcu-memo/health.svg)

```
[![Health](https://phpackages.com/badges/ksamborski-apcu-memo/health.svg)](https://phpackages.com/packages/ksamborski-apcu-memo)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
