Posted by yrashk
I’ve decided that I definitely need to celebrate Caches.rb first birthday soon. It was first announced on Sep 16, 2006. So I’m going to release next version on Sep 16, 2007. It is much better these days, but all that goodies are still in trunk. Recently I was even paid by a good folks that use Caches.rb in production to improve it even more. Thank you!
Currently caches.rb is available at:
- Subversion: http://svn.verbdev.com/rb/caches.rb/trunk/
- Browser: http://rb.dev.verbdev.com/browser/caches.rb
So, what we we have now? Class methods support, memcached storage (and, basically, pluggable storages), working Rails support [we had some issues with development environment].
What I’m going to do when have few minutes available? I’d like to pay more attention to tests (rewrite them?), create an up-to-date documentation. Anybody willing to help? I don’t have really much time these days since I’m busy working on an Issues Done startup and consulting for a living.
Also I’m open to read all bug reports, ideas, suggestions, patches you have in mind that you think should go into 1.0.
Posted by yrashk
I have extracted Caches.rb from Frontcamp finally and made it available to public.
You can fetch it from Subversion repository:
|
svn co svn://verbdev.com/rubylibs/caches.rb/trunk caches.rb |
Or you can install it as Rails plugin
|
ruby script/plugin install svn://verbdev.com/rubylibs/caches.rb/trunk |
or
|
ruby script/plugin install -x svn://verbdev.com/rubylibs/caches.rb/trunk |
Or you can install it using Gem, either download it or type something like
|
sudo gem install cachesrb |
Posted by yrashk
I’ve updated Caches a bit.
Now you can do
|
invalidate_all_caches :except => :name |
or
|
invalidate_all_caches :except => [:name, :name1] |
Also, it seems that I’ve fixed few bugs.
It is still not tested much, but should work.
You can find it here (as always)
Posted by yrashk
While working on Frontcamp we’ve found that we need to cache some methods.
You can find out quick hack solution there
Simply insert
|
ActiveRecord::Base.extend Caches::ClassMethods |
in your config/environment.rb and you will be able to specify
or
|
caches :method_name, :timeout => 2.minutes |
in your models.
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 explicitely with invalidate_method_name_cache and invalidate_all_method_name_caches calls.