twistor/lru-cache

LRU cache implementation

v1.0.0 2019-11-18 19:57 UTC

This package is auto-updated.

Last update: 2024-10-19 08:23:55 UTC


README

Author Build Status Coverage Status Quality Score Software License Packagist Version Total Downloads

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

composer require twistor/lru-cache

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;
});