Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 24 lines (16 sloc) 0.753 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Caches.rb
=========

Caches.rb is a simplistic method cache for Ruby

Simply do `BaseClass.extend Caches' and you will be able to specify

caches :method_name
or
caches :method_name, :timeout => 2.minutes

Default timeout is 60 seconds.

What is important is that this solution caches calls with arguments. For example, if you will make a method_name(“Hello”) call you’ll get next method_name(“Hello”) cached, but method_name(“Bye”) will not be cached.

Also you will be able to invalidate cache explicitly with invalidate_method_name_cache and invalidate_all_method_name_caches calls.

Also you can invalidate caches with

invalidate_all_caches
or
invalidate_all_caches :except => :name
or
invalidate_all_caches :except => [:name, :name1]
Something went wrong with that request. Please try again.