Simple file-based persistance for Ruby
Fast to use and setup method to cache intermediate result for utilities using ruby's gem named filecache. Excerpt from the README:
require 'rubygems'
require 'filecache'
# create a new cache called "my-cache", rooted in /home/simon/caches
# with an expiry time of 30 seconds, and a file hierarchy three
# directories deep
cache = FileCache.new("my-cache", "/home/simon/caches", 30, 3)
cache.put("joe", "bloggs")
puts(cache.get("joe")) # Returns bloggs
sleep 30
puts(cache.get("joe")) # Returns nil
Written by Przemysław Kamiński
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#