This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Wed Jul 09 05:15:44 -0700 2008 | |
| |
README | Mon Jul 14 11:44:33 -0700 2008 | |
| |
Rakefile | Wed Jul 09 05:15:44 -0700 2008 | |
| |
init.rb | Wed Jul 09 05:15:44 -0700 2008 | |
| |
install.rb | Wed Jul 09 05:15:44 -0700 2008 | |
| |
lib/ | Mon Jul 14 11:44:33 -0700 2008 | |
| |
tasks/ | Wed Jul 09 05:15:44 -0700 2008 | |
| |
test/ | Wed Jul 16 09:34:04 -0700 2008 | |
| |
uninstall.rb | Wed Jul 09 05:15:44 -0700 2008 |
README
MethodCache =========== A Rails (v2.1.0) plugin that tries to solve the problem of having to call a method repetitively. That method is expensive to be recalculated everytime. The solution is to cache the method results and we've always done that by caching a method's result in instance variables. method_cache plugin frees you from the trouble of worrying about writing caching code and introduces a couple of utility methods in ActiveRecord objects that make your life easier. In its current form, the plugin provides the following extensions to ActiveRecord Objects caches_method :method_name caches_class_method :method_name and for expiring the cache instance.expire_method :method_name Class.expire_instance_method :method_name, id Class.expire_class_method :method_name Introducing the plugin blog entry ================================= http://humanzz.spaces.live.com/blog/cns!82322F9506CB0449!713.entry Setup ===== ruby script/plugin install git://github.com/humanzz/method_cache.git Examples ======== For caching instance methods class User < ActiveRecord::Base def costy_method #some real heavy calculation that takes alot of resources #to complete #this method is called regularly and its results rarely change end caches_method :costy_method end class User < ActiveRecord::Base def costy_method #some real heavy calculation that takes alot of resources #to complete #this method is called regularly and its results rarely change end caches_method :costy_method, :for => 20.minutes end class User < ActiveRecord::Base def costy_method #some real heavy calculation that takes alot of resources #to complete #this method is called regularly and its results rarely change end caches_method :costy_method, :until => :midnight end :until also accepts Time and date objects but I'm considering removing until or have it support things like :midnight because otherwise it would cause errors after the specified date or time have passed. To expire cached instance methods @user.expire_method :costy_method User.expire_instance_method :costy_method, user_id For caching class methods class User < ActiveRecord::Base def self.costy_class_method #some real heavy calculation that takes alot of resources #to complete #this method is called regularly and its results rarely change end caches_class_method :costy_class_method end caches_class_method also supports the :for and :until options To expire class methods User.expire_class_method :costy_class_method Test ==== rake test:plugins DB=sqlite3 Copyright (c) 2008 humanzz (Ahmed Sobhi), released under the MIT license







