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 today

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

23

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

2463d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/42400?v=4)[Chris Leppanen](/maintainers/twistor)[@twistor](https://github.com/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

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15196.8k7](/packages/rapidwebltd-rw-file-cache)[yuzuru-s/redis-recommend

Wrapping Redis's sorted set APIs for specializing recommending operations.

392.9k](/packages/yuzuru-s-redis-recommend)[ichhabrecht/intcache

Turn uncachable page objects into cacheable links

193.9k](/packages/ichhabrecht-intcache)

PHPackages © 2026

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