PHPackages                             twistor/lru-cache - 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. twistor/lru-cache

ActiveLibrary[Caching](/categories/caching)

twistor/lru-cache
=================

LRU cache implementation

v1.0.0(6y ago)03MITPHPPHP ^7.2CI failing

Since Nov 18Pushed 6y agoCompare

[ Source](https://github.com/twistor/lru-cache)[ Packagist](https://packagist.org/packages/twistor/lru-cache)[ RSS](/packages/twistor-lru-cache/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

LRU Cache
=========

[](#lru-cache)

[![Author](https://camo.githubusercontent.com/500fb500f7a40e695210673a6780846051d0a17b3e1f79138f08165460f2999f/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d4063687269736c657070616e656e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/chrisleppanen)[![Build Status](https://camo.githubusercontent.com/397ac53b12f01ed5bba61baa6d2ac24fb9cf0624d59fe0c845ecf2fc813ea6e0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f74776973746f722f6c72752d63616368652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/twistor/lru-cache)[![Coverage Status](https://camo.githubusercontent.com/668d181444094c01a9777cf2e9d9291003ccfa2a28e8279adce7c1370b0325a1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f74776973746f722f6c72752d63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/twistor/lru-cache/code-structure)[![Quality Score](https://camo.githubusercontent.com/578e26763991d10c236e05c790d692d87ee4487f0386a1fe55a24028ba18fce5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74776973746f722f6c72752d63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/twistor/lru-cache)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/3c2957513a8233c668808585b5bfb88f8a5f18e8fca089db7515fa5368129350/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74776973746f722f6c72752d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/twistor/lru-cache)[![Total Downloads](https://camo.githubusercontent.com/4c03a0ea81f2ec39567ecdbe7e73508afdeb58f11f508b4dde7fd978ba181644/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74776973746f722f6c72752d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/twistor/lru-cache)

An LRU (least recently used) cache allows you to keep an in memory cache of objects. The oldest cache items will be removed once the capacity limit is reached.

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

[](#installation)

```
composer require twistor/lru-cache
```

Usage
-----

[](#usage)

```
use Twistor\LruCache;

$cache = new LruCache(100);

$cache->put('my_key', 1);

$cache->get('my_key');

$cache->getWith('new_key', function ($key) {
   return 2;
});
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

2372d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5125606781d4fe5f77b01cd43ae43863dd8d5ccde938e7b25dc7a40d0d46eb07?d=identicon)[twistor](/maintainers/twistor)

---

Top Contributors

[![twistor](https://avatars.githubusercontent.com/u/42400?v=4)](https://github.com/twistor "twistor (16 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/twistor-lru-cache/health.svg)

```
[![Health](https://phpackages.com/badges/twistor-lru-cache/health.svg)](https://phpackages.com/packages/twistor-lru-cache)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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