2017 © Pedro PelĂĄez
 

library lrucache

PHP LRU Cache implementation

image

nicklasw/lrucache

PHP LRU Cache implementation

  • Monday, October 24, 2016
  • by NicklasWallgren
  • Repository
  • 1 Watchers
  • 1 Stars
  • 117 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

Build Status Coverage Status, (*1)

PHP LRU Cache implementation

Forked from https://github.com/rogeriopvl/php-lrucache, (*2)

Changes * Reduce cost of inserting to cache from O(n) to O(1) * Make cache iterable * Fix phpunit tests, (*3)

Intro

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., (*4)

If you want more details about LRU Cache, you can read [this article]0 that explains it pretty well. Also if you want more interesting info, you can read this great paper on LRU algorithms., (*5)

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, (*6)

This implementation is similar to a LinkedHashMap. 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., (*7)

Install (composer)

Add the package into your composer.json file:, (*8)

"require": {
    "justin-robinson/lrucache": "dev-master"
}

Then run the command:, (*9)

composer install

Usage

Usage is pretty simple:, (*10)

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., (*11)

The Versions

24/10 2016

dev-master

9999999-dev https://github.com/NicklasWallgren/php-lrucache

PHP LRU Cache implementation

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

cache php lru

07/12 2014
24/07 2013

v0.2.1

0.2.1.0 https://github.com/rogeriopvl/php-lrucache

PHP LRU Cache implementation

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

cache php lru

24/07 2013

dev-develop

dev-develop https://github.com/rogeriopvl/php-lrucache

PHP LRU Cache implementation

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

cache php lru

10/03 2013

v0.1.3

0.1.3.0 https://github.com/rogeriopvl/php-lrucache

PHP LRU Cache implementation

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

cache php lru