Skip to content

TyperEJ/lru-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LRU Cache for PHP

https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU

Usage

use EJLin\LruCache\Cache;

$LRUCache = new Cache(2);

$LRUCache->put(1,1);
$LRUCache->put(2,2);
$LRUCache->get(1); // 1
$LRUCache->put(3,3);
$LRUCache->get(2); // -1 (not found)
$LRUCache->put(4,4);
$LRUCache->get(1); // -1 (not found)
$LRUCache->get(3); // 3
$LRUCache->get(4); // 4

$LRUCache->toArray(); // [4 => 4, 3 => 3];

About

LRU Cache for PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages