Project

filecache

0.02
Low commit activity in last 3 years
No release in over a year
A file-based caching library
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 11, > 11
~> 4, > 4
~> 3, > 3
 Project Readme

filecache

Gem Version

FileCache is a file-based caching library for Ruby.

Install

gem install filecache

or

gem 'filecache'

Usage

The following code will create a cache called my-cache rooted at /tmp/caches with an expiry time of 30 seconds, and a file hierarchy three directories deep.

require 'filecache'

cache = FileCache.new("my-cache", "/tmp/caches", 30, 3)
cache.set("key", "value")
puts(cache.get("key")) # "value"
sleep 30
puts(cache.get("key")) # nil
cache.get_or_set("key") { 1 } # 1
cache.get_or_set("key") { 2 } # 1 (cached value is returned, block is not executed)

Thanks

Thanks to Simon Whitaker who created this ruby gem.