Permalink
Browse files

change name to method_cachable

  • Loading branch information...
1 parent 34c8d84 commit 08f4300c62bb465c6a946b0d4a5380e26b49cec2 @schneems committed Dec 12, 2011
View
@@ -12,14 +12,14 @@ require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
- gem.name = "johnny_cache"
- gem.homepage = "http://github.com/Schnems/johnny_cache"
+ gem.name = "method_cacheable"
+ gem.homepage = "http://github.com/Schnems/method_cacheable"
gem.license = "MIT"
gem.summary = %Q{
Cache methods quickly and easily.
}
gem.description = %Q{
- "I've Been Everywhere" and I'm tired of writing cache wrappers "One Piece at a Time" for methods. So if you no longer want to "Walk the Line" then JohnnyCache can help to easily cache your ruby methods. Use this Gem or else you'll get thrown into the "Ring of Fire".
+ Cache methods quickly and easily
}
gem.email = "richard.schneeman@gmail.com"
gem.authors = ["Schneems"]
@@ -1,15 +1,13 @@
-require 'rubygems' #todo remove
-
require 'keytar'
require 'active_support/concern'
-# include JohnnyCache
+# include MethodCachable
#
#
# @example
# class User < ActiveRecord::Base
-# include JohnnyCache
+# include MethodCachable
#
# def expensive_method(val)
# sleep 120
@@ -36,8 +34,8 @@
#
# # SOOOOOOOO FAST!!
#
-# @see JohnnyCache#cache More info on cache options
-module JohnnyCache
+# @see MethodCachable#cache More info on cache options
+module MethodCachable
extend ActiveSupport::Concern
STORE = nil || Rails.cache
@@ -72,7 +70,7 @@ def cache(*args)
module ClassMethods
- # @see JohnnyCache#cache
+ # @see MethodCachable#cache
def cache(*args)
MethodCache.new(self, *args)
end
@@ -97,7 +95,7 @@ def initialize(caller_object, *method_cache_args)
# @see http://github.com/schneems/keytar Keytar, it builds keys
# @return the key used to set the cache
# @example
- # cache = User.find(263619).cache # => #<JohnnyCache::MethodCache ... >
+ # cache = User.find(263619).cache # => #<MethodCachable::MethodCache ... >
# cache.method = "foo" # => "foo"
# cache.key # => "users:foo:263619"
def key
@@ -111,20 +109,20 @@ def key
# @see http://api.rubyonrails.org/classes/ActionController/Caching.html#method-i-cache Rails.cache documentation
def call_cache_operation(options = {})
if cache_operation == :fetch
- JohnnyCache::STORE.fetch(key, options) do
+ MethodCachable::STORE.fetch(key, options) do
caller_object.send method.to_sym, *args
end
elsif cache_operation == :read
- JohnnyCache::STORE.read(key, options)
+ MethodCachable::STORE.read(key, options)
elsif cache_operation == :write
val = caller_object.send method.to_sym, *args
- JohnnyCache::STORE.write(key, val, options)
+ MethodCachable::STORE.write(key, val, options)
end
end
# Methods caught by method_missing are passed to the caller_object and used to :write, :read, or :fetch from the cache
#
- # @see JohnnyCache#cache
+ # @see MethodCachable#cache
def method_missing(method, *args, &blk)
if caller_object.respond_to? method
self.method = method
View
@@ -1,15 +1,13 @@
The Cache in Black
==================
-Cache method calls and speed up your Ruby on Rails application with JohnnyCache.
+Cache method calls and speed up your Ruby on Rails application with MethodCachable.
-Johnny Cache
+Method Cacheable
============
-I fell into a burning ring of (slow) methods, but they were cached cached cached, so the they came back super fast...
-
``` ruby
class User < ActiveRecord::Base
- include JohnnyCache
+ include MethodCachable
has_many :pictures
@@ -45,11 +43,11 @@ Install
=======
in your Gemfile
- gem 'johnny_cache'
+ gem 'method_cachable'
then in your models
- include JohnnyCache
+ include MethodCachable
Usage
@@ -99,66 +97,6 @@ Any configuration options passed to the cache method will be passed to the cache
```
-One Piece at a Time
-===================
-
- ...._........................................._____.............................
- ...| |........ |...... .... ............./ ___|........... .. |....... ...
- ...| |.. _ \.. __ \.. __ \.. __ \.. |.. |....| |...... _` |.. __|. __ \... _ \..
- /\_| |. ( |. |.| |. |.. |. |.. |. |.. |....| |..... (. |. (.... |.| |. __/..
- \___/..\___/.._|.|_|._|.._|._|.._|.\__, |.....\____|.\__,_|.\___|._|.|_|.\___|..
- ...................................____/........................................
- :......................................... .?DDNND8888ZN?.. ....
- ,......................................... $NMMMMNNMMNDMMN8 . ..
- ,..................................... ...7DMMMNMMMMMNMMDDN.. ....
- ,.....................................~~~DO887:~~=77OO7$$O. . ....
- ,.....................................,,.MMDI=:,.,,:~=~:~?D.. ....
- ,.....................................,,NMM8I=~:~=+?????~:$?.. .....
- :.....................................,,NMMO?~~~~:=?++===:=?.... ......
- ,.....................................,,8MMI+++?I7$$777I+=~..... ......
- ,.....................................,88ZM?IZ8ODNMOODMN887..... ............
- :.....................................,I7M?7==$DMMNI:NMM8++..... ..............
- ,.....................................,,$=I??=~78I==:=OZ+:......................
- :.....................................,,,7Z?I777:I~:,=I?I:......................
- :.....................................,,::~77I?=?=IOD$$?I:......................
- :.....................................:,:OMO$7I+I~~$O=$I7: .....................
- ~::::,,,,,,,,,,,,,,,,,,,,,,,,:::,:::::::88N$D8D8$8DM8ZD$~~............... ......
- ~::::::,,,,,,,,,,,,:,,:::,:?,:::,:7ODZNDMMMMMMND?+7O77NMZ~ ...... .... ........
- ~~:::::::,,,,,,,:::::,:$ZO8DO88NNDONDZNMMMMMMMNNMMMMMMMNN8+?I7$ZZZZOOO88DDNM, ..
- ~~~::::::::::::::,:I8D88DNNDD8NNND8NONMMMMMMMMMMMMMMMMMNDDD88MMMMMMMMMMMMNMN, .
- ~~~~:::::::::~:?D8O8D8NMMMMNNDNNDNDDDMNMNMMMMMMMMMMMMMMNNDN8ZZO8MNNNNNNNNDDD....
- ==~~~::::::::$DN8NMNDMMMMMMMDDMNDNNNMMMMMMMMMMMMMMMMMMMMNNDD87$88OZDDDDDDDDD,...
- ===~~~~~~:~?8DDDNNNNMMMMMMMMMNDNMMMNMMMMMMMNMMMMMMMMMMMMMNDDDN+=ZMNDDDNND8?~....
- =+=:ZO7$8O8NDDDDNNNMMMMMMMMMMMMNDMMMMNNMMMMMMMMMMMMMMNNNNNNNDDM=ZNDN88OII77$$$$$
- ==MNNNMMNDNNMNDDNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNDD8DNM=8NDNMNZZZZZZZZZ
- ZMMNDDNNMMMMMM?====~~7MMMMMMMMMMMMMMMMMMMMMMMMMMNNNNMNNNMMMMMMMMO=DMMNN8ZZZOOZZZ
- MDDNNNNMNMMO=+++==~~~~==MMMMMMMMMMMMMMMMMMMMMMMMMMNNNNMMMMNMOMMMM=~MMNNNOOOOOOOO
- DMNNMMDNMM7?+=++++===~=~~ZOMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM?MMMMM~~MMNNOOOOOOOO
- MMMNDDMNMMZ7I?+++=====+==~=MMMMMMMMNMMMMMMMNMMMMMMMMMMMMMMMM8MMMMMM.,MNNDOOO88O8
- 8MMNDDNNNMO7I+?+===++=====~=+MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM..NNN888888O
- ZMMZ,.~MMM8I+~::~===+==+=+++=++DMMMMMNMMMMMMMMMMMMMMMMMMMMMMMMMMNMMMZ,=ND888888O
- Z?~:,...MMDZI+~~~:~:::~~=++?+=+++++=+==~~,NMMMMMMMMMMMMMMMMMMMMMNNNNNDI?ND88888O
- I7+~:,..+MD$I?+==~==~~~~~~~~~~~~?+?+======++MMMMMMMMMMMMMMMMMMMMMMMNMMN8DD8888OO
- ?ZI=:,.. ND$I?++~:MM~=+++=+====~~~:::~~==++=NMMMMMMMMMMMMMMMMMMMMNMMMMD8ND888OOO
- :IZ=~:,,..?ZI?++IDZZ=======+++?++==~~=~~~:::7ONMMMMMMMMMMMMMMMMMNMMMMMMN=Z888888
- :7$7:~:,..,......:D~~=,+==++I7I?+++=++++=++=I77NMMMMMMMMMMMMMMMMMNMMNNMMMNI$8888
- :77Z~~+~:,.. . ,::::,7MI?$?OMM7I$?++++=+?++=Z$$78NMMMMMMMMMMMMMMMMMNMMMMNND~D888
- .,:?7?+?=:,:,..,O8O7I7$ZO$IMMMMMII???++++??ZNZZ$$8MMMMMMMMMMMMMMMMMMMMNNNNDMODD8
- ......~??~~~:,..=8NNMMDZMMD8MMDDZI?????++?+MMMMMMNMMMMMMMMMMMMMMMMMMMMMMMNNMNDD8
- ........~++~:=~: IMMMMDDMMNNMMMNO8D8?=++??7MMMMMMMMMMMMMMMMMMMMMMMNNNNNNDNNNMM88
- .. .,====II:..MM8?MMMMMMMMMDDZZOO$DO7DNMMMMMMMMMMMMMMMDMMMMMMMMMNNNNDNNDMN8
- .. . .=7~:?8?I,8MIMMMMMMMM8ZZNN8DD7ND8D88O$MMMMMMMMMMMMMMMMMMMMNNNNNNNDNDND
- .. ..~,+~:+MDI~+$IMMMMMM?MMM$8MD8D$MO8Z8OOON8?8NMMMMMZ8MMMMMMMNNNNNMMNDDDN
- .. ,::7I77NM8Z7O?ODO+OI+I8MD$NDMDOMDNDNNO8DM87DDIZN7IMMMMMMMMMMNNNNNNNDD
- . :7$?7OI7OMM8NMMMMM7++?IIII?ZMM8N8OZD8MNZIND8DN8OZDOIDMMMMMNM8=~INNNDD
- . ,IZO$7DDZZ8MMMMNM=+?I?IIIIIIMMMMMMMMONZD8$NNZ8Z8D8D8O8D8ZZ~:::::::NDD
- .. . .,=$D8N8MOMMDMZ~=+++???I7IIMMMMMMMMMMMMMNNN8NDD8DDZ8,D7NDO7ND$7I=~:,,
- .. .,+OO8OOZI+++???+++??I7I8MMMMMMMDMMMMMMMMMMMZNNDODNDNDDD88DDZZDD$?=
- .. ...=?I?==+++??III?I??IIZMMMMMMMMMMMMMMMMMMMMM$ZDMNN$NNN$ND8I=?~:Z$8
-
-
-
-
Contribution
============
@@ -1,7 +1,7 @@
require 'spec_helper'
-describe JohnnyCache::MethodCache do
+describe MethodCachable::MethodCache do
before(:all) do
@user = User.new
end
@@ -1,7 +1,7 @@
require 'spec_helper'
-describe JohnnyCache do
+describe MethodCachable do
before(:each) do
@user = User.new
@uniq ||= 0
View
@@ -24,9 +24,9 @@ def self.read(key, options)
end
-require 'johnny_cache'
+require 'method_cachable'
class User
- include JohnnyCache
+ include MethodCachable
define_keys :foo
def foo(var=nil)

0 comments on commit 08f4300

Please sign in to comment.