public
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-more.git
finally found the bug, inconsistent usage of @memcache.[sg]et cause 
tracking to not work complete.  woot for partial match expiration
atmos (author)
Tue Jul 08 17:34:48 -0700 2008
commit  28c3079e9d08adf41a040b1f7cea045441ef7809
tree    ec6ae3c908291497a8654516e1cb4ac41a3ee320
parent  e2a8eb2f2f69cf213ef20588a66de2906308123a
...
24
25
26
27
 
28
29
30
...
39
40
41
42
 
43
44
45
...
62
63
64
65
 
66
67
68
69
 
70
71
72
...
83
84
85
86
 
87
88
89
...
98
99
100
101
 
102
103
104
...
109
110
111
112
 
113
114
115
...
122
123
124
 
125
126
127
128
129
130
 
131
132
133
...
24
25
26
 
27
28
29
30
...
39
40
41
 
42
43
44
45
...
62
63
64
 
65
66
 
67
 
68
69
70
71
...
82
83
84
 
85
86
87
88
...
97
98
99
 
100
101
102
103
...
108
109
110
 
111
112
113
114
...
121
122
123
124
125
126
 
 
 
 
127
128
129
130
0
@@ -24,7 +24,7 @@ class Merb::Cache::MemcacheStore
0
     namespace = @config[:namespace] || 'merb-cache'
0
     host = @config[:host] || '127.0.0.1:11211'
0
     @memcache = MemCache.new(host, {:namespace => namespace})
0
- @tracking_key = "_#{namespace}_keys" unless @config[:no_tracking]
0
+ @tracking_key = "_#{namespace}_keys" unless @config[:no_tracking] == true
0
     raise NotReady unless @memcache.active?
0
     true
0
   rescue NameError
0
@@ -39,7 +39,7 @@ class Merb::Cache::MemcacheStore
0
   # ==== Returns
0
   # true if the cache entry exists, false otherwise
0
   def cached?(key)
0
- not @memcache.get(key).nil?
0
+ not cache_get(key).nil?
0
   end
0
 
0
   # Capture or restore the data in cache.
0
@@ -62,11 +62,10 @@ class Merb::Cache::MemcacheStore
0
   # It uses the capture_#{engine} and concat_#{engine} methods to do so.
0
   # The captured data are then marshalled and stored.
0
   def cache(_controller, key, from_now = nil, &block)
0
- _data = @memcache.get(key)
0
+ _data = cache_get(key)
0
     if _data.nil?
0
- _expire = from_now ? from_now.minutes.from_now.to_i : 0
0
       _data = _controller.send(:capture, &block)
0
- @memcache.set(key, _data, _expire)
0
+ cache_set(key, _data, from_now)
0
     end
0
     _controller.send(:concat, _data, block.binding)
0
     true
0
@@ -83,7 +82,7 @@ class Merb::Cache::MemcacheStore
0
     _expire = from_now ? from_now.minutes.from_now.to_i : 0
0
     @memcache.set(key, data, _expire)
0
     cache_start_tracking(key)
0
- Merb.logger.info("cache: set (#{key})")
0
+ Merb.logger.info!("cache: set (#{key})")
0
     true
0
   end
0
 
0
@@ -98,7 +97,7 @@ class Merb::Cache::MemcacheStore
0
   # nil is returned whether the entry expired or was not found
0
   def cache_get(key)
0
     data = @memcache.get(key)
0
- Merb.logger.info("cache: #{data.nil? ? "miss" : "hit"} (#{key})")
0
+ Merb.logger.info!("cache: #{data.nil? ? "miss" : "hit"} (#{key})")
0
     data
0
   end
0
 
0
@@ -109,7 +108,7 @@ class Merb::Cache::MemcacheStore
0
   def expire(key)
0
     @memcache.delete(key)
0
     cache_stop_tracking(key)
0
- Merb.logger.info("cache: expired (#{key})")
0
+ Merb.logger.info!("cache: expired (#{key})")
0
     true
0
   end
0
 
0
@@ -122,12 +121,10 @@ class Merb::Cache::MemcacheStore
0
   # In memcache this requires to keep track of all keys (on by default).
0
   # If you don't need this, set :no_tracking => true in the config.
0
   def expire_match(key)
0
+ Merb.logger.debug!("cache: attempting to expire #{key}")
0
     if @tracking_key
0
       for _key in get_tracked_keys
0
- if /#{key}/ =~ _key
0
- expire(_key)
0
- Merb.logger.info("cache: expired #{_key}")
0
- end
0
+ expire(_key) if /#{key}/ =~ _key
0
       end
0
     else
0
       Merb.logger.info("cache: expire_match is not supported with memcache (set :no_tracking => false in your config")
...
20
21
22
 
23
24
25
...
20
21
22
23
24
25
26
0
@@ -20,6 +20,7 @@ def use_cache_store(store, orm = nil)
0
     :store => store,
0
     :cache_directory => File.dirname(__FILE__) / "tmp/cache",
0
     :cache_html_directory => File.dirname(__FILE__) / "tmp/html",
0
+ :no_tracking => false
0
   }
0
   FileUtils.rm_rf(Dir.glob(File.dirname(__FILE__) / "/tmp"))
0
   case store

Comments

    No one has commented yet.