PHPackages                             jerryjean/lrucache - 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. jerryjean/lrucache

ActiveLibrary[Caching](/categories/caching)

jerryjean/lrucache
==================

PHP LRU Cache implementation

v1.1.1(5y ago)08Apache-2.0PHPPHP &gt;=5.4.0

Since Mar 9Pushed 5y agoCompare

[ Source](https://github.com/jerryjean/php-lrucache)[ Packagist](https://packagist.org/packages/jerryjean/lrucache)[ Docs](https://github.com/jerryjean/php-lrucache)[ RSS](/packages/jerryjean-lrucache/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (15)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c70243ecd03e2bcf7f45a4ffc5d3a06762b92e759e6a51797890abb1b28215ed/68747470733a2f2f7472617669732d63692e6f72672f6a757374696e2d726f62696e736f6e2f7068702d6c727563616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/justin-robinson/php-lrucache)[![Coverage Status](https://camo.githubusercontent.com/41df71cd7715f80b0553e601ef114232316bb3337a1eed39e301cea90b49d915/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6a757374696e2d726f62696e736f6e2f7068702d6c727563616368652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/justin-robinson/php-lrucache?branch=master)

PHP LRU Cache implementation
============================

[](#php-lru-cache-implementation)

Forked from \[\]

Changes

- Make methods protected instead of private

Intro
-----

[](#intro)

### What is a LRU Cache?

[](#what-is-a-lru-cache)

LRU stands for Least Recently Used. It's a type of cache that usually has a fixed capacity and discards the oldest entries. This is specially useful if you have the need to control the cache memory usage.

If you want more details about LRU Cache, you can read [this article](http://java-planet.blogspot.pt/2005/08/how-to-set-up-simple-lru-cache-using.html) that explains it pretty well. Also if you want more interesting info, you can read [this great paper on LRU algorithms](http://www.vldb.org/conf/1994/P439.PDF).

### Implementation

[](#implementation)

This code is in it's early stages. I need to write more tests to find out the possible naive code parts in order to achieve some performance, if any is possible with PHP :P

This implementation is similar to a [LinkedHashMap](http://docs.oracle.com/javase/7/docs/api/java/util/LinkedHashMap.html). Right now I'm just messing around with the code and decided to keep it simple, using a simple associative array as a naive hashmap.

Install (composer)
------------------

[](#install-composer)

Add the package into your `composer.json` file:

```
"require": {
    "jerryjean/lrucache": "dev-master"
}

```

Then run the command:

```
composer install

```

Usage
-----

[](#usage)

Usage is pretty simple:

```
require_once('vendor/autoload.php'); // composer autoader

$cache = new \LRUCache\LRUCache(1000);

$cache->put('mykey', 'arrow to the knee');

echo $cache->get('mykey');

```

You can use the tests to try things like load testing etc.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 85% 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 ~229 days

Recently: every ~397 days

Total

13

Last Release

2056d ago

Major Versions

v0.6.0 → v1.0.02016-05-17

PHP version history (2 changes)v0.1.3PHP &gt;=5.3.0

v0.4.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/75f3b42417f0396da5fa9b205c08b8d73e545612712c7acdf6e94681b95be356?d=identicon)[jerry.jean-baptiste](/maintainers/jerry.jean-baptiste)

---

Top Contributors

[![rogeriopvl](https://avatars.githubusercontent.com/u/38240?v=4)](https://github.com/rogeriopvl "rogeriopvl (34 commits)")[![jerryjean](https://avatars.githubusercontent.com/u/17931090?v=4)](https://github.com/jerryjean "jerryjean (5 commits)")[![nicolas-zozol](https://avatars.githubusercontent.com/u/912634?v=4)](https://github.com/nicolas-zozol "nicolas-zozol (1 commits)")

---

Tags

phpcachelru

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jerryjean-lrucache/health.svg)

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

###  Alternatives

[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

975163.6k2](/packages/awssat-laravel-visits)[lrucache/lrucache

PHP LRU Cache implementation

67117.1k3](/packages/lrucache-lrucache)[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[eftec/cacheone

A Cache library with minimum dependency

103.5k4](/packages/eftec-cacheone)

PHPackages © 2026

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