Project

lru_qache

0.0
No commit activity in last 3 years
No release in over 3 years
A simple LRU(Least Recently Used) Cache implementation using Ruby Hash
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.9
~> 0.9.25
 Project Readme

LRUQache

The LRU(least recently used) caching scheme is to remove the least recently used item when the cache reaches it's defined capacity. This gem implements this cache using a core Hash which is ordered hash. But this will work only if Ruby version is greater than 1.9.

Installation

Add this line to your application's Gemfile:

gem 'lru_qache'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install lru_qache

Usage

require "lru_qache"

# create a new cache with a 100 items capacity.
cache = LRUQache.new(100)

# set an item in cache
cache.set('key', 'your_value')

cache.get('key')
# returns 'your_value'

Documentation

YARD is used for generating documentation Generate documentation using yardoc lib/**/*.rb and open doc/index.html in browser.

Test

To run the test cases

rspec spec/*

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/datt/lru_qache.

License

The gem is available as open source under the terms of the MIT License.