PHPackages                             garyr/memento - 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. [Caching](/categories/caching)
4. /
5. garyr/memento

ActiveLibrary[Caching](/categories/caching)

garyr/memento
=============

Lightweight cache library

1.1.5(6y ago)196.6k6[2 issues](https://github.com/garyr/memento/issues)1MITPHPPHP &gt;=5.3.3

Since Jun 18Pushed 6y ago2 watchersCompare

[ Source](https://github.com/garyr/memento)[ Packagist](https://packagist.org/packages/garyr/memento)[ RSS](/packages/garyr-memento/feed)WikiDiscussions develop Synced today

READMEChangelogDependencies (3)Versions (12)Used By (1)

[![Build Status](https://camo.githubusercontent.com/114dc3ff6b956f9f882f458bf6bb294a442798c808a323b9667ad11f322206dc/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f67617279722f6d656d656e746f2e706e67)](http://travis-ci.org/garyr/memento)

Memento
=======

[](#memento)

Thin php caching wrapper for file, memcache, or redis storage engines. Supports simple key =&gt; data object storage and invalidation, as well as group based methods. Note that group bases methods always expire at the same time and should only be used when invalidation operations need to happen simultaneously

Setup
-----

[](#setup)

```
$file = new Memento\Engine\File(
    array(
        'path' => '/tmp/memento',   // defaults to sys_get_temp_dir() . '/memento'
    )
);

// client instance (defaults to file based storage)
$memento = new Memento\Client($file);
```

Memcache Setup
--------------

[](#memcache-setup)

```
$memcache = new Memento\Engine\Memcache(
    array(
        'host' => '127.0.0.1',
        'port' => 11211
    )
);

// client instance
$memento = new Memento\Client($memcache);
```

Redis Setup
-----------

[](#redis-setup)

```
$redis = new Memento\Engine\Redis(
    array(
        'host' => '127.0.0.1',
        'port' => 6379
    )
);

// client instance
$memento = new Memento\Client($redis);
```

Store Example
-------------

[](#store-example)

```
// single key store request
$memento->store(new Memento\Key('com.example.key'), array('mydata'));

$groupKey = new Memento\Group\Key('com.example.group1');

// group key store request (multiple keys per group key)
$memento->store(
    $groupKey,
    new Memento\Key('com.example.key1'),
    array('mydata')
);

$memento->store(
    $groupKey,
    new Memento\Key('com.example.key2'),
    array('foo' => 'bar')
);
```

Retrieve Example
----------------

[](#retrieve-example)

```
// single key retrieve request
$data = $memento->retrieve(new Memento\Key('com.example.key'));

$groupKey = new Memento\Group\Key('com.example.group1');

// group key retrieve request
$data = $memento->retrieve(
    $groupKey,
    new Memento\Key('com.example.key1')
);

$data = $memento->retrieve(
    $groupKey,
    new Memento\Key('com.example.key2')
);
```

Invalidate Example
------------------

[](#invalidate-example)

```
// single key invalidate request
$memento->invalidate(new Memento\Key('com.example'));

// group key store request (invalidate a group in a single operation)
$memento->invalidate(new Memento\Group\Key('com.example.group1'));
```

Sharding
--------

[](#sharding)

For other than file based engines, sharding simply requires additional hosts. Sharding is accomplished based on the key supplied for the data and is pointed to a host (see Memento\\Engine\\EngineAbstract)

```
// redis sharding config example
$redis = new Memento\Engine\Redis(
    array(
        array(
            'host' => 'redis1.mydomain',
            'port' => 6379
        ),
        array(
            'host' => 'redis2.mydomain',
            'port' => 6379
        )
    )
);

// memcache sharding config example
$memcache = new Memento\Engine\Memcache(
    array(
        array(
            'host' => 'memcache1.mydomain',
            'port' => 11211
        ),
        array(
            'host' => 'memcache2.mydomain',
            'port' => 11211
        )
    )
);
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 82.7% 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 ~209 days

Recently: every ~183 days

Total

10

Last Release

2462d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8bf345071f76d882894af6efe175ec8ddfafbae1521e50ea133135a8c5727ae1?d=identicon)[garyr](/maintainers/garyr)

---

Top Contributors

[![garyr](https://avatars.githubusercontent.com/u/449938?v=4)](https://github.com/garyr "garyr (43 commits)")[![bshaffer](https://avatars.githubusercontent.com/u/103941?v=4)](https://github.com/bshaffer "bshaffer (5 commits)")[![zhileiyang](https://avatars.githubusercontent.com/u/12176120?v=4)](https://github.com/zhileiyang "zhileiyang (3 commits)")[![teefax](https://avatars.githubusercontent.com/u/14892?v=4)](https://github.com/teefax "teefax (1 commits)")

---

Tags

rediscachefilememcache

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/garyr-memento/health.svg)

```
[![Health](https://phpackages.com/badges/garyr-memento/health.svg)](https://phpackages.com/packages/garyr-memento)
```

###  Alternatives

[matomo/cache

PHP caching library based on Doctrine cache

38854.1k4](/packages/matomo-cache)[ihor/cachalot

Cache a lot in a proper way (APC, XCache, Memcached, Redis, Couchbase)

2528.1k](/packages/ihor-cachalot)[bnomei/kirby3-redis-cachedriver

Advanced Redis cache-driver with in-memory store, transactions and preloading

101.7k](/packages/bnomei-kirby3-redis-cachedriver)

PHPackages © 2026

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