cache_fu 0.2.0.pre2 → 0.2.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/acts_as_cached/cache_methods.rb +4 -7
- data/lib/acts_as_cached/railtie.rb +6 -0
- data/lib/cache_fu.rb +0 -7
- metadata +4 -26
@@ -43,7 +43,7 @@ module ActsAsCached
|
|
43
43
|
keys_map = Hash[*keys.zip(cache_ids).flatten]
|
44
44
|
|
45
45
|
# Call get_multi and figure out which keys were missed based on what was a hit
|
46
|
-
hits =
|
46
|
+
hits = Rails.cache.read_multi(*keys) || {}
|
47
47
|
|
48
48
|
# Misses can take the form of key => nil
|
49
49
|
hits.delete_if { |key, value| value.nil? }
|
@@ -78,10 +78,9 @@ module ActsAsCached
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def set_cache(cache_id, value, options = nil)
|
81
|
-
value.
|
82
|
-
|
83
|
-
|
84
|
-
end
|
81
|
+
v = value.nil? ? @@nil_sentinel : value
|
82
|
+
Rails.cache.write(cache_key(cache_id), v, options)
|
83
|
+
value
|
85
84
|
end
|
86
85
|
|
87
86
|
def expire_cache(cache_id = nil)
|
@@ -143,13 +142,11 @@ module ActsAsCached
|
|
143
142
|
alias :cached :caches
|
144
143
|
|
145
144
|
def cached?(cache_id = nil)
|
146
|
-
return false if ActsAsCached.config[:skip_gets]
|
147
145
|
Rails.cache.exist?(cache_key(cache_id))
|
148
146
|
end
|
149
147
|
alias :is_cached? :cached?
|
150
148
|
|
151
149
|
def fetch_cache(cache_id)
|
152
|
-
return if ActsAsCached.config[:skip_gets]
|
153
150
|
Rails.cache.read(cache_key(cache_id))
|
154
151
|
end
|
155
152
|
|
@@ -8,6 +8,12 @@ module ActsAsCached
|
|
8
8
|
extend ActsAsCached::Mixin
|
9
9
|
end
|
10
10
|
|
11
|
+
if File.exists?(config_file = Rails.root.join('config', 'memcached.yml'))
|
12
|
+
ActsAsCached.config = YAML.load(ERB.new(IO.read(config_file)).result)
|
13
|
+
else
|
14
|
+
ActsAsCached.config = {}
|
15
|
+
end
|
16
|
+
|
11
17
|
ActiveSupport.on_load :action_controller do
|
12
18
|
include ActsAsCached::MemcacheRuntime
|
13
19
|
end
|
data/lib/cache_fu.rb
CHANGED
@@ -36,10 +36,3 @@ module ActsAsCached
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
40
|
-
Rails::Application.initializer("cache_fu") do
|
41
|
-
if File.exists?(config_file = Rails.root.join('config', 'memcached.yml'))
|
42
|
-
ActsAsCached.config = YAML.load(ERB.new(IO.read(config_file)).result)
|
43
|
-
end
|
44
|
-
ActsAsCached.config = {}
|
45
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
- pre2
|
11
|
-
version: 0.2.0.pre2
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.2.0.pre3
|
12
6
|
platform: ruby
|
13
7
|
authors:
|
14
8
|
- Surendra Singhi
|
@@ -16,7 +10,7 @@ autorequire:
|
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
12
|
|
19
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-31 00:00:00 +05:30
|
20
14
|
default_executable:
|
21
15
|
dependencies:
|
22
16
|
- !ruby/object:Gem::Dependency
|
@@ -27,10 +21,6 @@ dependencies:
|
|
27
21
|
requirements:
|
28
22
|
- - ~>
|
29
23
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 7
|
31
|
-
segments:
|
32
|
-
- 3
|
33
|
-
- 0
|
34
24
|
version: "3.0"
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
@@ -42,10 +32,6 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - ~>
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 7
|
46
|
-
segments:
|
47
|
-
- 3
|
48
|
-
- 0
|
49
35
|
version: "3.0"
|
50
36
|
type: :development
|
51
37
|
version_requirements: *id002
|
@@ -88,25 +74,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
74
|
requirements:
|
89
75
|
- - ">="
|
90
76
|
- !ruby/object:Gem::Version
|
91
|
-
hash: 3
|
92
|
-
segments:
|
93
|
-
- 0
|
94
77
|
version: "0"
|
95
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
79
|
none: false
|
97
80
|
requirements:
|
98
81
|
- - ">"
|
99
82
|
- !ruby/object:Gem::Version
|
100
|
-
hash: 25
|
101
|
-
segments:
|
102
|
-
- 1
|
103
|
-
- 3
|
104
|
-
- 1
|
105
83
|
version: 1.3.1
|
106
84
|
requirements: []
|
107
85
|
|
108
86
|
rubyforge_project:
|
109
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.6.2
|
110
88
|
signing_key:
|
111
89
|
specification_version: 3
|
112
90
|
summary: Makes caching easy for ActiveRecord models
|