method_cacheable 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/{method_cachable.rb → method_cacheable.rb} +10 -10
- data/method_cacheable.gemspec +7 -7
- data/pkg/method_cacheable-0.0.1.gem +0 -0
- data/readme.md +4 -4
- data/spec/{method_cachable → method_cacheable}/method_cache_spec.rb +1 -1
- data/spec/{method_cachable_spec.rb → method_cacheable_spec.rb} +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +9 -9
- data/johnny_cache.gemspec +0 -96
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -2,12 +2,12 @@ require 'keytar'
|
|
2
2
|
require 'active_support/concern'
|
3
3
|
|
4
4
|
|
5
|
-
# include
|
5
|
+
# include MethodCacheable
|
6
6
|
#
|
7
7
|
#
|
8
8
|
# @example
|
9
9
|
# class User < ActiveRecord::Base
|
10
|
-
# include
|
10
|
+
# include MethodCacheable
|
11
11
|
#
|
12
12
|
# def expensive_method(val)
|
13
13
|
# sleep 120
|
@@ -34,8 +34,8 @@ require 'active_support/concern'
|
|
34
34
|
#
|
35
35
|
# # SOOOOOOOO FAST!!
|
36
36
|
#
|
37
|
-
# @see
|
38
|
-
module
|
37
|
+
# @see MethodCacheable#cache More info on cache options
|
38
|
+
module MethodCacheable
|
39
39
|
extend ActiveSupport::Concern
|
40
40
|
STORE = nil || Rails.cache
|
41
41
|
|
@@ -70,7 +70,7 @@ module MethodCachable
|
|
70
70
|
|
71
71
|
|
72
72
|
module ClassMethods
|
73
|
-
# @see
|
73
|
+
# @see MethodCacheable#cache
|
74
74
|
def cache(*args)
|
75
75
|
MethodCache.new(self, *args)
|
76
76
|
end
|
@@ -95,7 +95,7 @@ module MethodCachable
|
|
95
95
|
# @see http://github.com/schneems/keytar Keytar, it builds keys
|
96
96
|
# @return the key used to set the cache
|
97
97
|
# @example
|
98
|
-
# cache = User.find(263619).cache # => #<
|
98
|
+
# cache = User.find(263619).cache # => #<MethodCacheable::MethodCache ... >
|
99
99
|
# cache.method = "foo" # => "foo"
|
100
100
|
# cache.key # => "users:foo:263619"
|
101
101
|
def key
|
@@ -109,20 +109,20 @@ module MethodCachable
|
|
109
109
|
# @see http://api.rubyonrails.org/classes/ActionController/Caching.html#method-i-cache Rails.cache documentation
|
110
110
|
def call_cache_operation(options = {})
|
111
111
|
if cache_operation == :fetch
|
112
|
-
|
112
|
+
MethodCacheable::STORE.fetch(key, options) do
|
113
113
|
caller_object.send method.to_sym, *args
|
114
114
|
end
|
115
115
|
elsif cache_operation == :read
|
116
|
-
|
116
|
+
MethodCacheable::STORE.read(key, options)
|
117
117
|
elsif cache_operation == :write
|
118
118
|
val = caller_object.send method.to_sym, *args
|
119
|
-
|
119
|
+
MethodCacheable::STORE.write(key, val, options)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
# Methods caught by method_missing are passed to the caller_object and used to :write, :read, or :fetch from the cache
|
124
124
|
#
|
125
|
-
# @see
|
125
|
+
# @see MethodCacheable#cache
|
126
126
|
def method_missing(method, *args, &blk)
|
127
127
|
if caller_object.respond_to? method
|
128
128
|
self.method = method
|
data/method_cacheable.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "method_cacheable"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Schneems"]
|
@@ -37,14 +37,14 @@ Gem::Specification.new do |s|
|
|
37
37
|
"doc/js/jquery.js",
|
38
38
|
"doc/method_list.html",
|
39
39
|
"doc/top-level-namespace.html",
|
40
|
-
"
|
41
|
-
"lib/method_cachable.rb",
|
40
|
+
"lib/method_cacheable.rb",
|
42
41
|
"license.txt",
|
43
42
|
"method_cacheable.gemspec",
|
44
43
|
"pkg/johnny_cache-0.0.1.gem",
|
44
|
+
"pkg/method_cacheable-0.0.1.gem",
|
45
45
|
"readme.md",
|
46
|
-
"spec/
|
47
|
-
"spec/
|
46
|
+
"spec/method_cacheable/method_cache_spec.rb",
|
47
|
+
"spec/method_cacheable_spec.rb",
|
48
48
|
"spec/spec_helper.rb"
|
49
49
|
]
|
50
50
|
s.homepage = "http://github.com/Schnems/method_cacheable"
|
@@ -53,8 +53,8 @@ Gem::Specification.new do |s|
|
|
53
53
|
s.rubygems_version = "1.8.10"
|
54
54
|
s.summary = "Cache methods quickly and easily."
|
55
55
|
s.test_files = [
|
56
|
-
"spec/
|
57
|
-
"spec/
|
56
|
+
"spec/method_cacheable/method_cache_spec.rb",
|
57
|
+
"spec/method_cacheable_spec.rb",
|
58
58
|
"spec/spec_helper.rb"
|
59
59
|
]
|
60
60
|
|
Binary file
|
data/readme.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
The Cache in Black
|
2
2
|
==================
|
3
|
-
Cache method calls and speed up your Ruby on Rails application with
|
3
|
+
Cache method calls and speed up your Ruby on Rails application with MethodCacheable.
|
4
4
|
|
5
5
|
Method Cacheable
|
6
6
|
============
|
7
7
|
|
8
8
|
``` ruby
|
9
9
|
class User < ActiveRecord::Base
|
10
|
-
include
|
10
|
+
include MethodCacheable
|
11
11
|
|
12
12
|
has_many :pictures
|
13
13
|
|
@@ -43,11 +43,11 @@ Install
|
|
43
43
|
=======
|
44
44
|
in your Gemfile
|
45
45
|
|
46
|
-
gem '
|
46
|
+
gem 'method_cacheable'
|
47
47
|
|
48
48
|
then in your models
|
49
49
|
|
50
|
-
include
|
50
|
+
include MethodCacheable
|
51
51
|
|
52
52
|
|
53
53
|
Usage
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: method_cacheable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Schneems
|
@@ -180,14 +180,14 @@ files:
|
|
180
180
|
- doc/js/jquery.js
|
181
181
|
- doc/method_list.html
|
182
182
|
- doc/top-level-namespace.html
|
183
|
-
-
|
184
|
-
- lib/method_cachable.rb
|
183
|
+
- lib/method_cacheable.rb
|
185
184
|
- license.txt
|
186
185
|
- method_cacheable.gemspec
|
187
186
|
- pkg/johnny_cache-0.0.1.gem
|
187
|
+
- pkg/method_cacheable-0.0.1.gem
|
188
188
|
- readme.md
|
189
|
-
- spec/
|
190
|
-
- spec/
|
189
|
+
- spec/method_cacheable/method_cache_spec.rb
|
190
|
+
- spec/method_cacheable_spec.rb
|
191
191
|
- spec/spec_helper.rb
|
192
192
|
homepage: http://github.com/Schnems/method_cacheable
|
193
193
|
licenses:
|
@@ -223,6 +223,6 @@ signing_key:
|
|
223
223
|
specification_version: 3
|
224
224
|
summary: Cache methods quickly and easily.
|
225
225
|
test_files:
|
226
|
-
- spec/
|
227
|
-
- spec/
|
226
|
+
- spec/method_cacheable/method_cache_spec.rb
|
227
|
+
- spec/method_cacheable_spec.rb
|
228
228
|
- spec/spec_helper.rb
|
data/johnny_cache.gemspec
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{johnny_cache}
|
8
|
-
s.version = "0.0.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [%q{Schneems}]
|
12
|
-
s.date = %q{2011-08-08}
|
13
|
-
s.description = %q{
|
14
|
-
"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".
|
15
|
-
}
|
16
|
-
s.email = %q{richard.schneeman@gmail.com}
|
17
|
-
s.files = [
|
18
|
-
".rvmrc",
|
19
|
-
".yardoc/checksums",
|
20
|
-
".yardoc/objects/root.dat",
|
21
|
-
".yardoc/proxy_types",
|
22
|
-
"Gemfile",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"autotest/discover.rb",
|
26
|
-
"doc/JohnnyCache.html",
|
27
|
-
"doc/JohnnyCache/ClassMethods.html",
|
28
|
-
"doc/JohnnyCache/MethodCache.html",
|
29
|
-
"doc/_index.html",
|
30
|
-
"doc/class_list.html",
|
31
|
-
"doc/css/common.css",
|
32
|
-
"doc/css/full_list.css",
|
33
|
-
"doc/css/style.css",
|
34
|
-
"doc/file_list.html",
|
35
|
-
"doc/frames.html",
|
36
|
-
"doc/index.html",
|
37
|
-
"doc/js/app.js",
|
38
|
-
"doc/js/full_list.js",
|
39
|
-
"doc/js/jquery.js",
|
40
|
-
"doc/method_list.html",
|
41
|
-
"doc/top-level-namespace.html",
|
42
|
-
"lib/johnny_cache.rb",
|
43
|
-
"license.txt",
|
44
|
-
"readme.md",
|
45
|
-
"spec/johnny_cache/method_cache_spec.rb",
|
46
|
-
"spec/johnny_cache_spec.rb",
|
47
|
-
"spec/spec_helper.rb"
|
48
|
-
]
|
49
|
-
s.homepage = %q{http://github.com/Schnems/johnny_cache}
|
50
|
-
s.licenses = [%q{MIT}]
|
51
|
-
s.require_paths = [%q{lib}]
|
52
|
-
s.rubygems_version = %q{1.8.6}
|
53
|
-
s.summary = %q{Cache methods quickly and easily.}
|
54
|
-
s.test_files = [
|
55
|
-
"spec/johnny_cache/method_cache_spec.rb",
|
56
|
-
"spec/johnny_cache_spec.rb",
|
57
|
-
"spec/spec_helper.rb"
|
58
|
-
]
|
59
|
-
|
60
|
-
if s.respond_to? :specification_version then
|
61
|
-
s.specification_version = 3
|
62
|
-
|
63
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
64
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
65
|
-
s.add_runtime_dependency(%q<keytar>, [">= 0"])
|
66
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
67
|
-
s.add_development_dependency(%q<rdiscount>, [">= 0"])
|
68
|
-
s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
|
69
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
70
|
-
s.add_development_dependency(%q<autotest-standalone>, [">= 0"])
|
71
|
-
s.add_development_dependency(%q<autotest-growl>, [">= 0"])
|
72
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
73
|
-
else
|
74
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
75
|
-
s.add_dependency(%q<keytar>, [">= 0"])
|
76
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
77
|
-
s.add_dependency(%q<rdiscount>, [">= 0"])
|
78
|
-
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
79
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
80
|
-
s.add_dependency(%q<autotest-standalone>, [">= 0"])
|
81
|
-
s.add_dependency(%q<autotest-growl>, [">= 0"])
|
82
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
83
|
-
end
|
84
|
-
else
|
85
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
86
|
-
s.add_dependency(%q<keytar>, [">= 0"])
|
87
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
88
|
-
s.add_dependency(%q<rdiscount>, [">= 0"])
|
89
|
-
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
90
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
91
|
-
s.add_dependency(%q<autotest-standalone>, [">= 0"])
|
92
|
-
s.add_dependency(%q<autotest-growl>, [">= 0"])
|
93
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|