merb-cache 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/Rakefile +33 -55
- data/lib/merb-cache/cache-action.rb +27 -15
- data/lib/merb-cache/cache-page.rb +13 -4
- data/lib/merb-cache/cache-store/database-datamapper.rb +15 -15
- data/lib/merb-cache/cache-store/database.rb +1 -1
- data/lib/merb-cache/cache-store/file.rb +3 -1
- data/lib/merb-cache/cache-store/memcache.rb +14 -10
- data/lib/merb-cache/merb-cache.rb +5 -5
- data/lib/merb-cache.rb +1 -1
- data/spec/controller.rb +44 -1
- data/spec/log/merb_test.log +433 -0
- data/spec/merb-cache-action_spec.rb +56 -0
- data/spec/spec_helper.rb +1 -0
- metadata +10 -7
data/README
CHANGED
@@ -89,7 +89,7 @@ Implemented cache stores:
|
|
89
89
|
#:store => "memcache",
|
90
90
|
#:host => "127.0.0.1:11211",
|
91
91
|
#:namespace => "merb_cache",
|
92
|
-
#:no_tracking =>
|
92
|
+
#:no_tracking => false,
|
93
93
|
|
94
94
|
#:store => "memory",
|
95
95
|
# store could be: file, memcache, memory, database, dummy, ...
|
data/Rakefile
CHANGED
@@ -1,80 +1,58 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require "rake/rdoctask"
|
3
2
|
require 'rake/gempackagetask'
|
4
|
-
require "
|
3
|
+
require "extlib"
|
4
|
+
require 'merb-core/tasks/merb_rake_helper'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
##############################################################################
|
7
|
+
# Package && release
|
8
|
+
##############################################################################
|
9
|
+
RUBY_FORGE_PROJECT = "merb"
|
10
|
+
PROJECT_URL = "http://merbivore.com"
|
11
|
+
PROJECT_SUMMARY = "Merb plugin that provides caching (page, action, fragment, object)"
|
12
|
+
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
13
|
+
|
14
|
+
GEM_AUTHOR = "Alex Boussinet"
|
15
|
+
GEM_EMAIL = "alex.boussinet@gmail.com"
|
16
|
+
|
17
|
+
GEM_NAME = "merb-cache"
|
18
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
19
|
+
GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.4") + PKG_BUILD
|
20
|
+
|
21
|
+
RELEASE_NAME = "REL #{GEM_VERSION}"
|
22
|
+
|
23
|
+
require "extlib/tasks/release"
|
14
24
|
|
15
25
|
spec = Gem::Specification.new do |s|
|
16
|
-
s.
|
17
|
-
s.
|
26
|
+
s.rubyforge_project = RUBY_FORGE_PROJECT
|
27
|
+
s.name = GEM_NAME
|
28
|
+
s.version = GEM_VERSION
|
18
29
|
s.platform = Gem::Platform::RUBY
|
19
30
|
s.has_rdoc = true
|
20
31
|
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
21
|
-
s.summary =
|
22
|
-
s.description =
|
23
|
-
s.author =
|
24
|
-
s.email =
|
25
|
-
s.homepage =
|
26
|
-
s.add_dependency('merb-core', '>= 0.9.
|
32
|
+
s.summary = PROJECT_SUMMARY
|
33
|
+
s.description = PROJECT_DESCRIPTION
|
34
|
+
s.author = GEM_AUTHOR
|
35
|
+
s.email = GEM_EMAIL
|
36
|
+
s.homepage = PROJECT_URL
|
37
|
+
s.add_dependency('merb-core', '>= 0.9.4')
|
27
38
|
s.require_path = 'lib'
|
28
|
-
s.autorequire = PLUGIN
|
29
39
|
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
30
|
-
|
31
|
-
# rdoc
|
32
|
-
s.has_rdoc = true
|
33
|
-
s.extra_rdoc_files = %w( README LICENSE TODO )
|
34
|
-
end
|
35
|
-
|
36
|
-
namespace :specs do
|
37
|
-
["file", "memory", "memcache", "sequel", "datamapper", "activerecord"].each do |store|
|
38
|
-
desc "Run spec with the \"#{store}\" cache store"
|
39
|
-
task "#{store}" do
|
40
|
-
cwd = Dir.getwd
|
41
|
-
Dir.chdir(File.dirname(__FILE__) + "/spec")
|
42
|
-
ENV["STORE"] = store
|
43
|
-
system("spec --format specdoc --colour merb-cache_spec.rb")
|
44
|
-
Dir.chdir(cwd)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
namespace :doc do
|
50
|
-
Rake::RDocTask.new do |rdoc|
|
51
|
-
files = ["README", "LICENSE", "lib/**/*.rb"]
|
52
|
-
rdoc.rdoc_files.add(files)
|
53
|
-
rdoc.main = "README"
|
54
|
-
rdoc.title = "merb-cache docs"
|
55
|
-
if File.file?("../../merb-core/tools/allison-2.0.2/lib/allison.rb")
|
56
|
-
rdoc.template = "../../merb-core/tools/allison-2.0.2/lib/allison.rb"
|
57
|
-
end
|
58
|
-
rdoc.rdoc_dir = "doc/rdoc"
|
59
|
-
rdoc.options << "--line-numbers" << "--inline-source"
|
60
|
-
end
|
61
40
|
end
|
62
41
|
|
63
42
|
Rake::GemPackageTask.new(spec) do |pkg|
|
64
43
|
pkg.gem_spec = spec
|
65
44
|
end
|
66
45
|
|
67
|
-
|
68
|
-
|
46
|
+
desc "Install the gem"
|
69
47
|
task :install => [:package] do
|
70
|
-
sh %{sudo gem install #{install_home} pkg/#{
|
48
|
+
sh %{#{sudo} gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}
|
71
49
|
end
|
72
50
|
|
73
51
|
namespace :jruby do
|
74
52
|
|
75
53
|
desc "Run :package and install the resulting .gem with jruby"
|
76
54
|
task :install => :package do
|
77
|
-
sh %{#{
|
55
|
+
sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
|
78
56
|
end
|
79
|
-
|
57
|
+
|
80
58
|
end
|
@@ -4,35 +4,47 @@ class Merb::Cache
|
|
4
4
|
end
|
5
5
|
|
6
6
|
module Merb::Cache::ControllerClassMethods
|
7
|
-
# Mixed in Merb::Controller. Provides methods related to action caching
|
7
|
+
# Mixed in Merb::Controller. Provides methods related to action caching.
|
8
8
|
|
9
|
-
#
|
9
|
+
# Registers an action for action caching via before and after filters.
|
10
10
|
#
|
11
11
|
# ==== Parameters
|
12
|
-
# action<Symbol>:: The name of the action to register
|
13
|
-
# from_now<~minutes>::
|
14
|
-
#
|
12
|
+
# action<Symbol>:: The name of the action to register.
|
13
|
+
# from_now<~minutes>:: The number of minutes (from now) the cache should persist.
|
14
|
+
# opts<Hash>::
|
15
|
+
# Filter options (see <tt>Filter Options</tt> in <tt>Merb::AbstractController</tt>). The filters created apply :only
|
16
|
+
# to specified <tt>action</tt>.
|
15
17
|
#
|
16
18
|
# ==== Examples
|
17
19
|
# cache_action :mostly_static
|
18
20
|
# cache_action :barely_dynamic, 10
|
19
|
-
|
20
|
-
|
21
|
+
# cache_action :list, :if => Proc.new { |controller| !controller.params[:id].empty? }
|
22
|
+
# cache_action :show, :unless => proc { |controller| !controller.params[:id].empty? }
|
23
|
+
def cache_action(action, from_now = nil, opts = {})
|
24
|
+
cache_actions([action, from_now, opts])
|
21
25
|
end
|
22
26
|
|
23
|
-
# Register actions for action caching
|
27
|
+
# Register multiple actions for action caching via before and after filters.
|
24
28
|
#
|
25
29
|
# ==== Parameter
|
26
|
-
# actions<Symbol,Array[Symbol,~minutes]>:: See #cache_action
|
30
|
+
# actions<Symbol,Array[Symbol,~minutes],Hash>:: See #cache_action.
|
27
31
|
#
|
28
32
|
# ==== Example
|
29
|
-
# cache_actions
|
33
|
+
# cache_actions(
|
34
|
+
# :mostly_static,
|
35
|
+
# [:barely_dynamic, 10],
|
36
|
+
# [:conditional, { :if => proc { |controller| controller.params[:id].empty? } }]
|
37
|
+
# )
|
30
38
|
def cache_actions(*actions)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
actions.each do |action, from_now, opts|
|
40
|
+
from_now, opts = nil, from_now if Hash === from_now
|
41
|
+
opts ||= {}
|
42
|
+
|
43
|
+
before("cache_#{action}_before", opts.merge(:only => action))
|
44
|
+
after("cache_#{action}_after", opts.merge(:only => action))
|
45
|
+
alias_method "cache_#{action}_before", :cache_action_before
|
46
|
+
alias_method "cache_#{action}_after", :cache_action_after
|
47
|
+
|
36
48
|
_actions = Merb::Cache.cached_actions[controller_name] ||= {}
|
37
49
|
_actions[action] = from_now
|
38
50
|
end
|
@@ -33,7 +33,7 @@ module Merb::Cache::ControllerClassMethods
|
|
33
33
|
before(:cache_page_before)
|
34
34
|
after(:cache_page_after)
|
35
35
|
end
|
36
|
-
pages.each do |action, from_now|
|
36
|
+
pages.each do |action, from_now|
|
37
37
|
_pages = Merb::Cache.cached_pages[controller_name] ||= {}
|
38
38
|
_pages[action] = [from_now, 0]
|
39
39
|
end
|
@@ -68,9 +68,17 @@ module Merb::Cache::ControllerInstanceMethods
|
|
68
68
|
# ==== Parameter
|
69
69
|
# options<String,Hash>:: The options that will be passed to #expire_key_for
|
70
70
|
#
|
71
|
-
# ==== Examples
|
71
|
+
# ==== Examples (See Merb::Cache#expire_key_for for more options)
|
72
|
+
# # will expire path/to/page/cache/news/show/1.html
|
73
|
+
# expire_page(:key => url(:news,News.find(1)))
|
74
|
+
#
|
75
|
+
# # will expire path/to/page/cache/news/show.html
|
72
76
|
# expire_page(:action => 'show', :controller => 'news')
|
77
|
+
#
|
78
|
+
# # will expire path/to/page/cache/news/show*
|
73
79
|
# expire_page(:action => 'show', :match => true)
|
80
|
+
#
|
81
|
+
# # will expire path/to/page/cache/news/show.js
|
74
82
|
# expire_page(:action => 'show', :extension => 'js')
|
75
83
|
def expire_page(options)
|
76
84
|
config_dir = Merb::Controller._cache.config[:cache_html_directory]
|
@@ -121,7 +129,8 @@ module Merb::Cache::ControllerInstanceMethods
|
|
121
129
|
return unless pages && pages.key?(action)
|
122
130
|
path = request.path.chomp("/")
|
123
131
|
path = "index" if path.empty?
|
124
|
-
|
132
|
+
no_format = params[:format].nil? || params[:format].empty?
|
133
|
+
ext = "." + (no_format ? DEFAULT_PAGE_EXTENSION : params[:format])
|
125
134
|
ext = nil if File.extname(path) == ext
|
126
135
|
cache_file = Merb::Controller._cache.config[:cache_html_directory] / "#{path}#{ext}"
|
127
136
|
if data
|
@@ -136,7 +145,7 @@ module Merb::Cache::ControllerInstanceMethods
|
|
136
145
|
if File.file?(cache_file)
|
137
146
|
_data = cache_read_page(cache_file)
|
138
147
|
_expire_in, _expire_at = pages[action]
|
139
|
-
if _expire_in.nil? || Time.now < _expire_at
|
148
|
+
if _expire_in.nil? || Time.now.to_i < _expire_at.to_i
|
140
149
|
Merb.logger.info("cache: hit (#{path})")
|
141
150
|
throw(:halt, _data)
|
142
151
|
end
|
@@ -2,11 +2,12 @@ module Merb::Cache::DatabaseStore::DataMapper
|
|
2
2
|
# Module that provides DataMapper support for the database backend
|
3
3
|
|
4
4
|
# The cache model
|
5
|
-
class CacheModel
|
6
|
-
|
7
|
-
|
8
|
-
property :
|
9
|
-
property :
|
5
|
+
class CacheModel
|
6
|
+
include DataMapper::Resource
|
7
|
+
storage_names[:default] = Merb::Controller._cache.config[:table_name]
|
8
|
+
property :ckey, String, :length => 255, :lazy => false, :key => true
|
9
|
+
property :data, Text, :lazy => false
|
10
|
+
property :expire, DateTime, :default => nil
|
10
11
|
|
11
12
|
# Fetch data from the database using the specified key
|
12
13
|
# The entry is deleted if it has expired
|
@@ -18,9 +19,9 @@ module Merb::Cache::DatabaseStore::DataMapper
|
|
18
19
|
# data<String, NilClass>::
|
19
20
|
# nil is returned whether the entry expired or was not found
|
20
21
|
def self.cache_get(key)
|
21
|
-
if entry = self.
|
22
|
+
if entry = self.get(key)
|
22
23
|
return entry.data if entry.expire.nil? || DateTime.now < entry.expire
|
23
|
-
entry.destroy
|
24
|
+
entry.destroy
|
24
25
|
end
|
25
26
|
nil
|
26
27
|
end
|
@@ -38,9 +39,9 @@ module Merb::Cache::DatabaseStore::DataMapper
|
|
38
39
|
# - when set to false, force creation of the cache entry
|
39
40
|
def self.cache_set(key, data, expire = nil, get = true)
|
40
41
|
attributes = {:ckey => key, :data => data,
|
41
|
-
:expire => expire
|
42
|
+
:expire => expire }
|
42
43
|
if get
|
43
|
-
entry = self.
|
44
|
+
entry = self.get(key)
|
44
45
|
entry.nil? ? self.create(attributes) : entry.update_attributes(attributes)
|
45
46
|
else
|
46
47
|
self.create(attributes)
|
@@ -53,8 +54,8 @@ module Merb::Cache::DatabaseStore::DataMapper
|
|
53
54
|
# ==== Parameter
|
54
55
|
# key<Sting>:: The key identifying the cache entry
|
55
56
|
def self.expire(key)
|
56
|
-
entry = self.
|
57
|
-
entry.destroy
|
57
|
+
entry = self.get(key)
|
58
|
+
entry.destroy unless entry.nil?
|
58
59
|
end
|
59
60
|
|
60
61
|
# Expire the cache entries matching the given key
|
@@ -62,18 +63,17 @@ module Merb::Cache::DatabaseStore::DataMapper
|
|
62
63
|
# ==== Parameter
|
63
64
|
# key<Sting>:: The key matching the cache entries
|
64
65
|
def self.expire_match(key)
|
65
|
-
#
|
66
|
-
database.execute("DELETE FROM #{self.table.name} WHERE ckey LIKE '#{key}%'")
|
66
|
+
self.all(:ckey.like => "#{key}%").destroy!
|
67
67
|
end
|
68
68
|
|
69
69
|
# Expire all the cache entries
|
70
70
|
def self.expire_all
|
71
|
-
self.
|
71
|
+
self.all.destroy!
|
72
72
|
end
|
73
73
|
|
74
74
|
# Perform auto-migration in case the table is unknown in the database
|
75
75
|
def self.check_table
|
76
|
-
self.
|
76
|
+
self.auto_upgrade!
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
class Merb::Cache::FileStore
|
2
3
|
# Provides the file cache store for merb-cache
|
3
4
|
|
@@ -8,7 +9,7 @@ class Merb::Cache::FileStore
|
|
8
9
|
prepare
|
9
10
|
end
|
10
11
|
|
11
|
-
class NotAccessible < Exception
|
12
|
+
class NotAccessible < Exception #
|
12
13
|
def initialize(message)
|
13
14
|
super("Cache directories are not readable/writeable (#{message})")
|
14
15
|
end
|
@@ -17,6 +18,7 @@ class Merb::Cache::FileStore
|
|
17
18
|
# This method is there to ensure minimal requirements are met
|
18
19
|
# (directories are accessible, table exists, connected to server, ...)
|
19
20
|
def prepare
|
21
|
+
FileUtils.mkdir_p @config[:cache_directory]
|
20
22
|
unless File.readable?(@config[:cache_directory]) &&
|
21
23
|
File.writable?(@config[:cache_directory])
|
22
24
|
raise NotAccessible, @config[:cache_directory]
|
@@ -6,13 +6,13 @@ class Merb::Cache::MemcacheStore
|
|
6
6
|
prepare
|
7
7
|
end
|
8
8
|
|
9
|
-
class NotReady < Exception
|
9
|
+
class NotReady < Exception
|
10
10
|
def initialize
|
11
11
|
super("Memcache server is not ready")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
class NotDefined < Exception
|
15
|
+
class NotDefined < Exception
|
16
16
|
def initialize
|
17
17
|
super("Memcache is not defined (require it in init.rb)")
|
18
18
|
end
|
@@ -24,7 +24,7 @@ class Merb::Cache::MemcacheStore
|
|
24
24
|
namespace = @config[:namespace] || 'merb-cache'
|
25
25
|
host = @config[:host] || '127.0.0.1:11211'
|
26
26
|
@memcache = MemCache.new(host, {:namespace => namespace})
|
27
|
-
@tracking_key = "_#{namespace}_keys" unless @config[:no_tracking]
|
27
|
+
@tracking_key = "_#{namespace}_keys" unless @config[:no_tracking] == true
|
28
28
|
raise NotReady unless @memcache.active?
|
29
29
|
true
|
30
30
|
rescue NameError
|
@@ -39,7 +39,7 @@ class Merb::Cache::MemcacheStore
|
|
39
39
|
# ==== Returns
|
40
40
|
# true if the cache entry exists, false otherwise
|
41
41
|
def cached?(key)
|
42
|
-
not
|
42
|
+
not cache_get(key).nil?
|
43
43
|
end
|
44
44
|
|
45
45
|
# Capture or restore the data in cache.
|
@@ -62,11 +62,10 @@ class Merb::Cache::MemcacheStore
|
|
62
62
|
# It uses the capture_#{engine} and concat_#{engine} methods to do so.
|
63
63
|
# The captured data are then marshalled and stored.
|
64
64
|
def cache(_controller, key, from_now = nil, &block)
|
65
|
-
_data =
|
65
|
+
_data = cache_get(key)
|
66
66
|
if _data.nil?
|
67
|
-
_expire = from_now ? from_now.minutes.from_now.to_i : 0
|
68
67
|
_data = _controller.send(:capture, &block)
|
69
|
-
|
68
|
+
cache_set(key, _data, from_now)
|
70
69
|
end
|
71
70
|
_controller.send(:concat, _data, block.binding)
|
72
71
|
true
|
@@ -83,7 +82,7 @@ class Merb::Cache::MemcacheStore
|
|
83
82
|
_expire = from_now ? from_now.minutes.from_now.to_i : 0
|
84
83
|
@memcache.set(key, data, _expire)
|
85
84
|
cache_start_tracking(key)
|
86
|
-
Merb.logger.info("cache: set (#{key})")
|
85
|
+
Merb.logger.info!("cache: set (#{key})")
|
87
86
|
true
|
88
87
|
end
|
89
88
|
|
@@ -98,7 +97,11 @@ class Merb::Cache::MemcacheStore
|
|
98
97
|
# nil is returned whether the entry expired or was not found
|
99
98
|
def cache_get(key)
|
100
99
|
data = @memcache.get(key)
|
101
|
-
|
100
|
+
if data.nil?
|
101
|
+
Merb.logger.info!("cache: miss (#{key})")
|
102
|
+
else
|
103
|
+
Merb.logger.debug!("cache: hit (#{key})")
|
104
|
+
end
|
102
105
|
data
|
103
106
|
end
|
104
107
|
|
@@ -109,7 +112,7 @@ class Merb::Cache::MemcacheStore
|
|
109
112
|
def expire(key)
|
110
113
|
@memcache.delete(key)
|
111
114
|
cache_stop_tracking(key)
|
112
|
-
Merb.logger.info("cache: expired (#{key})")
|
115
|
+
Merb.logger.info!("cache: expired (#{key})")
|
113
116
|
true
|
114
117
|
end
|
115
118
|
|
@@ -122,6 +125,7 @@ class Merb::Cache::MemcacheStore
|
|
122
125
|
# In memcache this requires to keep track of all keys (on by default).
|
123
126
|
# If you don't need this, set :no_tracking => true in the config.
|
124
127
|
def expire_match(key)
|
128
|
+
Merb.logger.debug!("cache: attempting to expire #{key}")
|
125
129
|
if @tracking_key
|
126
130
|
for _key in get_tracked_keys
|
127
131
|
expire(_key) if /#{key}/ =~ _key
|
@@ -5,7 +5,7 @@ require "merb-cache/cache-fragment"
|
|
5
5
|
class Merb::Cache
|
6
6
|
attr_reader :config, :store
|
7
7
|
|
8
|
-
class StoreNotFound < Exception
|
8
|
+
class StoreNotFound < Exception
|
9
9
|
def initialize(cache_store)
|
10
10
|
super("cache_store (#{cache_store}) not found (not implemented?)")
|
11
11
|
end
|
@@ -39,7 +39,7 @@ class Merb::Cache
|
|
39
39
|
# If the cache_store mentionned in the config is unknown
|
40
40
|
def start
|
41
41
|
@config = DEFAULT_CONFIG.merge(Merb::Plugins.config[:merb_cache] || {})
|
42
|
-
if @config[:disable] == true || Merb.environment == @config[:disable]
|
42
|
+
if @config[:disable] == true || Merb.environment.to_s == @config[:disable].to_s
|
43
43
|
config[:disable_page_caching] = true
|
44
44
|
config[:store] = "dummy"
|
45
45
|
end
|
@@ -146,13 +146,13 @@ class Merb::Cache
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
module Merb
|
150
|
-
class Controller
|
149
|
+
module Merb
|
150
|
+
class Controller
|
151
151
|
cattr_reader :_cache
|
152
152
|
@@_cache = Merb::Cache.new
|
153
153
|
# extends Merb::Controller with new instance methods
|
154
154
|
include Merb::Cache::ControllerInstanceMethods
|
155
|
-
class << self
|
155
|
+
class << self
|
156
156
|
# extends Merb::Controller with new class methods
|
157
157
|
include Merb::Cache::ControllerClassMethods
|
158
158
|
end
|
data/lib/merb-cache.rb
CHANGED
data/spec/controller.rb
CHANGED
@@ -3,13 +3,19 @@ class CacheController < Merb::Controller
|
|
3
3
|
|
4
4
|
cache_action :action3
|
5
5
|
cache_action :action4, 0.05
|
6
|
-
# or cache_actions :action3, [:action4, 0.05]
|
7
6
|
|
8
7
|
cache_page :action5
|
9
8
|
cache_page :action6, 0.05
|
10
9
|
# or cache_pages :action5, [:action6, 0.05]
|
11
10
|
cache_page :action7
|
12
11
|
|
12
|
+
cache_action :action8, 0.05, :if => proc {|controller| !controller.params[:id].empty?}
|
13
|
+
cache_action :action9, 0.05, :unless => proc {|controller| controller.params[:id].empty?}
|
14
|
+
cache_action :action10, :if => :non_empty_id?
|
15
|
+
cache_action :action11, :unless => :empty_id?
|
16
|
+
|
17
|
+
cache_actions :cache_actions_1, [:cache_actions_2, 0.05], [:cache_actions_3, { :if => :empty_id? }]
|
18
|
+
|
13
19
|
def action1
|
14
20
|
render
|
15
21
|
end
|
@@ -52,7 +58,44 @@ class CacheController < Merb::Controller
|
|
52
58
|
end
|
53
59
|
end
|
54
60
|
|
61
|
+
def action8
|
62
|
+
"test action8"
|
63
|
+
end
|
64
|
+
|
65
|
+
def action9
|
66
|
+
"test action9"
|
67
|
+
end
|
68
|
+
|
69
|
+
def action10
|
70
|
+
"test action10"
|
71
|
+
end
|
72
|
+
|
73
|
+
def action11
|
74
|
+
"test action11"
|
75
|
+
end
|
76
|
+
|
77
|
+
def cache_actions_1
|
78
|
+
'test cache_actions_1'
|
79
|
+
end
|
80
|
+
|
81
|
+
def cache_actions_2
|
82
|
+
'test cache_actions_2'
|
83
|
+
end
|
84
|
+
|
85
|
+
def cache_actions_3
|
86
|
+
'test cache_actions_3'
|
87
|
+
end
|
88
|
+
|
55
89
|
def index
|
56
90
|
"test index"
|
57
91
|
end
|
92
|
+
|
93
|
+
private
|
94
|
+
def empty_id?
|
95
|
+
params[:id].empty?
|
96
|
+
end
|
97
|
+
|
98
|
+
def non_empty_id?
|
99
|
+
!empty_id?
|
100
|
+
end
|
58
101
|
end
|
@@ -0,0 +1,433 @@
|
|
1
|
+
Mon, 21 Jul 2008 23:29:20 GMT ~ info ~ Logfile created
|
2
|
+
~ Using memcache cache
|
3
|
+
~ Not Using Sessions
|
4
|
+
~ Using memory cache
|
5
|
+
~ Not Using Sessions
|
6
|
+
~ cache: expired all
|
7
|
+
~ {:after_filters_time=>2.0e-05, :before_filters_time=>4.0e-05, :action_time=>0.000221}
|
8
|
+
~ {:after_filters_time=>4.0e-05, :before_filters_time=>2.5e-05, :action_time=>0.000792}
|
9
|
+
~ cache: hit (key1)
|
10
|
+
~ {:after_filters_time=>2.2e-05, :before_filters_time=>2.5e-05, :action_time=>0.000636}
|
11
|
+
~ cache: hit (key11)
|
12
|
+
~ {:after_filters_time=>4.5e-05, :before_filters_time=>9.4e-05, :action_time=>0.001524}
|
13
|
+
~ cache: hit (key11)
|
14
|
+
~ cache: expired (key11)
|
15
|
+
~ cache: miss (key11)
|
16
|
+
~ {:after_filters_time=>3.8e-05, :before_filters_time=>8.8e-05, :action_time=>0.001444}
|
17
|
+
~ cache: expired (key1)
|
18
|
+
~ cache: miss (key1)
|
19
|
+
~ {:after_filters_time=>3.1e-05, :before_filters_time=>4.0e-05, :action_time=>0.00092}
|
20
|
+
~ cache: miss (unknown_key)
|
21
|
+
~ cache: set (test1)
|
22
|
+
~ cache: hit (test1)
|
23
|
+
~ cache: set (test2)
|
24
|
+
~ cache: hit (test2)
|
25
|
+
~ cache: set (test3)
|
26
|
+
~ cache: hit (test3)
|
27
|
+
~ cache: expired matching (test)
|
28
|
+
~ cache: miss (test1)
|
29
|
+
~ cache: miss (test2)
|
30
|
+
~ cache: miss (test3)
|
31
|
+
~ cache: set (timed_key)
|
32
|
+
~ cache: hit (timed_key)
|
33
|
+
~ cache: miss (timed_key)
|
34
|
+
~ cache: set (test1)
|
35
|
+
~ cache: expired (test1)
|
36
|
+
~ cache: miss (test1)
|
37
|
+
~ cache: set (test2/id1)
|
38
|
+
~ cache: expired (test2/id1)
|
39
|
+
~ cache: miss (test2/id1)
|
40
|
+
~ cache: set (test3)
|
41
|
+
~ cache: expired (test3)
|
42
|
+
~ cache: miss (test3)
|
43
|
+
~ cache: set (test4/id1)
|
44
|
+
~ cache: expired matching (test4/id1)
|
45
|
+
~ cache: miss (test4/id1/id2)
|
46
|
+
~ cache: expired all
|
47
|
+
~ cache: miss (key1)
|
48
|
+
~ cache: set (key1)
|
49
|
+
~ cache: hit (key1)
|
50
|
+
~ cache: miss (/cache_controller/action3)
|
51
|
+
~ cache: set (/cache_controller/action3)
|
52
|
+
~ {:after_filters_time=>7.9e-05, :before_filters_time=>0.000111, :action_time=>0.000218}
|
53
|
+
~ cache: hit (/cache_controller/action3)
|
54
|
+
~ cache: expired (/cache_controller/action3)
|
55
|
+
~ cache: miss (/cache_controller/action3)
|
56
|
+
~ cache: miss (/cache_controller/action3/abc/456/ghi)
|
57
|
+
~ cache: set (/cache_controller/action3/abc/456/ghi)
|
58
|
+
~ {:after_filters_time=>6.9e-05, :before_filters_time=>7.9e-05, :action_time=>0.000163}
|
59
|
+
~ cache: hit (/cache_controller/action3/abc/456/ghi)
|
60
|
+
~ cache: hit (/cache_controller/action3/abc/456/ghi)
|
61
|
+
~ {:after_filters_time=>3.4e-05, :action_time=>0.00011}
|
62
|
+
~ cache: expired (/cache_controller/action3/abc/456/ghi)
|
63
|
+
~ cache: miss (/cache_controller/action3/abc/456/ghi)
|
64
|
+
~ cache: miss (/cache_controller/action4)
|
65
|
+
~ cache: set (/cache_controller/action4)
|
66
|
+
~ {:after_filters_time=>7.6e-05, :before_filters_time=>7.9e-05, :action_time=>0.00017}
|
67
|
+
~ cache: hit (/cache_controller/action4)
|
68
|
+
~ cache: miss (/cache_controller/action4)
|
69
|
+
~ cache: expired matching (/cache_controller/action4)
|
70
|
+
~ cache: miss (/cache_controller/action4/path/to/nowhere)
|
71
|
+
~ cache: set (/cache_controller/action4/path/to/nowhere)
|
72
|
+
~ {:after_filters_time=>9.5e-05, :before_filters_time=>0.000108, :action_time=>0.000227}
|
73
|
+
~ cache: miss (/cache_controller/action4/path/to/nowhere)
|
74
|
+
~ cache: miss (/cache_controller/action4)
|
75
|
+
~ cache: set (/cache_controller/action4)
|
76
|
+
~ {:after_filters_time=>9.2e-05, :before_filters_time=>0.000112, :action_time=>0.000225}
|
77
|
+
~ cache: expired (/cache_controller/action4)
|
78
|
+
~ cache: miss (/cache_controller/action4)
|
79
|
+
~ cache: set (/cache_controller/action4)
|
80
|
+
~ {:after_filters_time=>8.1e-05, :before_filters_time=>8.8e-05, :action_time=>0.000184}
|
81
|
+
~ cache: expired matching (/cache_control)
|
82
|
+
~ cache: miss (/cache_controller/action4)
|
83
|
+
~ cache: set (/cache_controller/action4)
|
84
|
+
~ {:after_filters_time=>7.2e-05, :before_filters_time=>7.8e-05, :action_time=>0.000164}
|
85
|
+
~ cache: expired (/cache_controller/action4)
|
86
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
87
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
88
|
+
~ {:after_filters_time=>7.3e-05, :before_filters_time=>7.8e-05, :action_time=>0.000164}
|
89
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
90
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
91
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
92
|
+
~ {:after_filters_time=>7.2e-05, :before_filters_time=>7.8e-05, :action_time=>0.000164}
|
93
|
+
~ cache: expired matching (/cache_controller/action4)
|
94
|
+
~ cache: miss (/cache_controller/action4)
|
95
|
+
~ cache: set (/cache_controller/action4)
|
96
|
+
~ {:after_filters_time=>7.3e-05, :before_filters_time=>7.7e-05, :action_time=>0.000164}
|
97
|
+
~ cache: expired (/cache_controller/action4)
|
98
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
99
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
100
|
+
~ {:after_filters_time=>7.2e-05, :before_filters_time=>7.7e-05, :action_time=>0.000163}
|
101
|
+
~ cache: expired matching (/cache_controller/action4/id1)
|
102
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
103
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
104
|
+
~ {:after_filters_time=>7.3e-05, :before_filters_time=>9.1e-05, :action_time=>0.000178}
|
105
|
+
~ cache: expired matching (/cache_controller/action4)
|
106
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
107
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
108
|
+
~ {:after_filters_time=>7.1e-05, :before_filters_time=>7.7e-05, :action_time=>0.000164}
|
109
|
+
~ cache: expired matching (/cache_controller/action4/id1)
|
110
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
111
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
112
|
+
~ {:after_filters_time=>7.3e-05, :before_filters_time=>9.1e-05, :action_time=>0.000178}
|
113
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
114
|
+
~ cache: miss (/cache_controller/action4)
|
115
|
+
~ cache: set (/cache_controller/action4)
|
116
|
+
~ {:after_filters_time=>7.2e-05, :before_filters_time=>9.1e-05, :action_time=>0.000177}
|
117
|
+
~ cache: expired (/cache_controller/action4)
|
118
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
119
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
120
|
+
~ {:after_filters_time=>6.5e-05, :before_filters_time=>8.3e-05, :action_time=>0.000161}
|
121
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
122
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
123
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
124
|
+
~ {:after_filters_time=>6.5e-05, :before_filters_time=>8.2e-05, :action_time=>0.00016}
|
125
|
+
~ cache: expired matching (/cache_controller/action4/id1)
|
126
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
127
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
128
|
+
~ {:after_filters_time=>5.0e-05, :before_filters_time=>5.8e-05, :action_time=>0.000119}
|
129
|
+
~ cache: expired matching (/cache_controller/action4/id1)
|
130
|
+
~ {:after_filters_time=>2.6e-05, :before_filters_time=>0.000175, :action_time=>0.000213}
|
131
|
+
~ cache: miss (/cache_controller/action8/cache)
|
132
|
+
~ cache: set (/cache_controller/action8/cache)
|
133
|
+
~ {:after_filters_time=>5.5e-05, :before_filters_time=>0.000142, :action_time=>0.000208}
|
134
|
+
~ {:after_filters_time=>2.6e-05, :before_filters_time=>0.000104, :action_time=>0.000141}
|
135
|
+
~ cache: miss (/cache_controller/action9/cache)
|
136
|
+
~ cache: set (/cache_controller/action9/cache)
|
137
|
+
~ {:after_filters_time=>5.6e-05, :before_filters_time=>0.000129, :action_time=>0.000194}
|
138
|
+
~ {:after_filters_time=>2.4e-05, :before_filters_time=>0.000106, :action_time=>0.000139}
|
139
|
+
~ cache: miss (/cache_controller/action10/cache)
|
140
|
+
~ cache: set (/cache_controller/action10/cache)
|
141
|
+
~ {:after_filters_time=>5.2e-05, :before_filters_time=>0.000126, :action_time=>0.000187}
|
142
|
+
~ {:after_filters_time=>2.4e-05, :before_filters_time=>0.000103, :action_time=>0.000136}
|
143
|
+
~ cache: miss (/cache_controller/action11/cache)
|
144
|
+
~ cache: set (/cache_controller/action11/cache)
|
145
|
+
~ {:after_filters_time=>5.1e-05, :before_filters_time=>0.000134, :action_time=>0.000195}
|
146
|
+
~ cache: set (/cache_controller/action5)
|
147
|
+
~ {:after_filters_time=>0.000414, :before_filters_time=>0.000163, :action_time=>0.000596}
|
148
|
+
~ cache: set (/cache_controller/action5/this/is/a/test)
|
149
|
+
~ {:after_filters_time=>0.001305, :before_filters_time=>0.000296, :action_time=>0.001627}
|
150
|
+
~ cache: set (/cache_controller/action6)
|
151
|
+
~ {:after_filters_time=>0.000582, :before_filters_time=>0.000236, :action_time=>0.000858}
|
152
|
+
~ cache: hit (/cache_controller/action6)
|
153
|
+
~ {:after_filters_time=>2.4e-05, :action_time=>0.000346}
|
154
|
+
~ cache: set (/cache_controller/action6)
|
155
|
+
~ {:after_filters_time=>0.000622, :before_filters_time=>0.0008, :action_time=>0.001475}
|
156
|
+
~ cache: set (/cache_controller/action6/path/to/nowhere)
|
157
|
+
~ {:after_filters_time=>0.001422, :before_filters_time=>0.000258, :action_time=>0.001737}
|
158
|
+
~ cache: hit (/cache_controller/action6/path/to/nowhere)
|
159
|
+
~ {:after_filters_time=>3.8e-05, :action_time=>0.000656}
|
160
|
+
~ cache: set (/cache_controller/action6/path/to/nowhere)
|
161
|
+
~ {:after_filters_time=>0.000387, :before_filters_time=>0.000445, :action_time=>0.000869}
|
162
|
+
~ cache: set (/cache_controller/action6)
|
163
|
+
~ {:after_filters_time=>0.000341, :before_filters_time=>0.000178, :action_time=>0.000543}
|
164
|
+
~ cache: set (/cache_controller/action6)
|
165
|
+
~ {:after_filters_time=>0.000574, :before_filters_time=>0.000164, :action_time=>0.000771}
|
166
|
+
~ cache: set (/cache_controller/action6)
|
167
|
+
~ {:after_filters_time=>0.000375, :before_filters_time=>0.000167, :action_time=>0.000575}
|
168
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
169
|
+
~ {:after_filters_time=>0.00086, :before_filters_time=>0.000183, :action_time=>0.001069}
|
170
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
171
|
+
~ {:after_filters_time=>0.000349, :before_filters_time=>0.00016, :action_time=>0.000536}
|
172
|
+
~ cache: set (/cache_controller/action6)
|
173
|
+
~ {:after_filters_time=>0.000367, :before_filters_time=>0.000149, :action_time=>0.000543}
|
174
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
175
|
+
~ {:after_filters_time=>0.000718, :before_filters_time=>0.000163, :action_time=>0.000908}
|
176
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
177
|
+
~ {:after_filters_time=>0.000332, :before_filters_time=>0.000141, :action_time=>0.000502}
|
178
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
179
|
+
~ {:after_filters_time=>0.000696, :before_filters_time=>0.000155, :action_time=>0.000877}
|
180
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
181
|
+
~ {:after_filters_time=>0.000397, :before_filters_time=>0.000154, :action_time=>0.000578}
|
182
|
+
~ cache: set (/cache_controller/action6)
|
183
|
+
~ {:after_filters_time=>0.000371, :before_filters_time=>0.00018, :action_time=>0.000577}
|
184
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
185
|
+
~ {:after_filters_time=>0.000358, :before_filters_time=>0.000172, :action_time=>0.000555}
|
186
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
187
|
+
~ {:after_filters_time=>0.000353, :before_filters_time=>0.000156, :action_time=>0.000544}
|
188
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
189
|
+
~ {:after_filters_time=>0.000337, :before_filters_time=>0.000151, :action_time=>0.000515}
|
190
|
+
~ cache: set (/cache_controller/action7.css)
|
191
|
+
~ {:after_filters_time=>0.000535, :before_filters_time=>0.000459, :action_time=>0.001035}
|
192
|
+
~ cache: hit (/cache_controller/action7.css)
|
193
|
+
~ {:after_filters_time=>2.7e-05, :action_time=>0.000552}
|
194
|
+
~ cache: set (/cache_controller/action7.js)
|
195
|
+
~ {:after_filters_time=>0.000539, :before_filters_time=>0.000381, :action_time=>0.000956}
|
196
|
+
~ cache: hit (/cache_controller/action7.js)
|
197
|
+
~ {:after_filters_time=>2.2e-05, :action_time=>0.0003}
|
198
|
+
~ cache: set (/cache_controller/action7.xml)
|
199
|
+
~ {:after_filters_time=>0.000405, :before_filters_time=>0.000169, :action_time=>0.000599}
|
200
|
+
~ cache: hit (/cache_controller/action7.xml)
|
201
|
+
~ {:after_filters_time=>2.1e-05, :action_time=>0.000263}
|
202
|
+
~ cache: set (/cache_controller/action7.jpg)
|
203
|
+
~ {:after_filters_time=>0.000331, :before_filters_time=>0.000173, :action_time=>0.000528}
|
204
|
+
~ cache: hit (/cache_controller/action7.jpg)
|
205
|
+
~ {:after_filters_time=>1.9e-05, :action_time=>0.000259}
|
206
|
+
~ cache: set (/cache_controller/action7.html)
|
207
|
+
~ {:after_filters_time=>0.000308, :before_filters_time=>0.00017, :action_time=>0.0005}
|
208
|
+
~ cache: hit (/cache_controller/action7.html)
|
209
|
+
~ {:after_filters_time=>2.2e-05, :action_time=>0.000288}
|
210
|
+
~ Using memcache cache
|
211
|
+
~ Not Using Sessions
|
212
|
+
~ cache: expired all
|
213
|
+
~ {:after_filters_time=>1.9e-05, :before_filters_time=>4.1e-05, :action_time=>0.000244}
|
214
|
+
~ cache: miss (key1)
|
215
|
+
~ cache: set (key1)
|
216
|
+
~ {:after_filters_time=>2.8e-05, :before_filters_time=>2.4e-05, :action_time=>0.00422}
|
217
|
+
~ cache: miss (key11)
|
218
|
+
~ cache: set (key11)
|
219
|
+
~ {:after_filters_time=>2.4e-05, :before_filters_time=>3.4e-05, :action_time=>0.001341}
|
220
|
+
~ {:after_filters_time=>2.7e-05, :before_filters_time=>4.9e-05, :action_time=>0.001105}
|
221
|
+
~ cache: expired (key11)
|
222
|
+
~ cache: miss (key11)
|
223
|
+
~ {:after_filters_time=>3.9e-05, :before_filters_time=>9.3e-05, :action_time=>0.001921}
|
224
|
+
~ cache: expired (key1)
|
225
|
+
~ cache: miss (key1)
|
226
|
+
~ cache: miss (key1)
|
227
|
+
~ cache: set (key1)
|
228
|
+
~ {:after_filters_time=>3.1e-05, :before_filters_time=>4.2e-05, :action_time=>0.001765}
|
229
|
+
~ cache: miss (unknown_key)
|
230
|
+
~ cache: set (test1)
|
231
|
+
~ cache: set (test2)
|
232
|
+
~ cache: set (test3)
|
233
|
+
~ cache: expired (test1)
|
234
|
+
~ cache: expired (test2)
|
235
|
+
~ cache: expired (test3)
|
236
|
+
~ cache: miss (test1)
|
237
|
+
~ cache: miss (test2)
|
238
|
+
~ cache: miss (test3)
|
239
|
+
~ cache: set (timed_key)
|
240
|
+
~ cache: miss (timed_key)
|
241
|
+
~ cache: set (test1)
|
242
|
+
~ cache: expired (test1)
|
243
|
+
~ cache: miss (test1)
|
244
|
+
~ cache: set (test2/id1)
|
245
|
+
~ cache: expired (test2/id1)
|
246
|
+
~ cache: miss (test2/id1)
|
247
|
+
~ cache: set (test3)
|
248
|
+
~ cache: expired (test3)
|
249
|
+
~ cache: miss (test3)
|
250
|
+
~ cache: set (test4/id1)
|
251
|
+
~ cache: expired (test4/id1)
|
252
|
+
~ cache: miss (test4/id1/id2)
|
253
|
+
~ cache: expired all
|
254
|
+
~ cache: miss (key1)
|
255
|
+
~ cache: set (key1)
|
256
|
+
~ cache: miss (/cache_controller/action3)
|
257
|
+
~ cache: set (/cache_controller/action3)
|
258
|
+
~ {:after_filters_time=>0.000491, :before_filters_time=>0.000238, :action_time=>0.000753}
|
259
|
+
~ cache: expired (/cache_controller/action3)
|
260
|
+
~ cache: miss (/cache_controller/action3)
|
261
|
+
~ cache: miss (/cache_controller/action3/abc/456/ghi)
|
262
|
+
~ cache: set (/cache_controller/action3/abc/456/ghi)
|
263
|
+
~ {:after_filters_time=>0.000458, :before_filters_time=>0.000186, :action_time=>0.000689}
|
264
|
+
~ {:after_filters_time=>2.3e-05, :action_time=>0.000186}
|
265
|
+
~ cache: expired (/cache_controller/action3/abc/456/ghi)
|
266
|
+
~ cache: miss (/cache_controller/action3/abc/456/ghi)
|
267
|
+
~ cache: miss (/cache_controller/action4)
|
268
|
+
~ cache: set (/cache_controller/action4)
|
269
|
+
~ {:after_filters_time=>0.000462, :before_filters_time=>0.000182, :action_time=>0.000656}
|
270
|
+
~ cache: miss (/cache_controller/action4)
|
271
|
+
~ cache: miss (/cache_controller/action4)
|
272
|
+
~ cache: expired (/cache_controller/action4)
|
273
|
+
~ cache: miss (/cache_controller/action4/path/to/nowhere)
|
274
|
+
~ cache: miss (/cache_controller/action4/path/to/nowhere)
|
275
|
+
~ cache: set (/cache_controller/action4/path/to/nowhere)
|
276
|
+
~ {:after_filters_time=>0.000713, :before_filters_time=>0.000315, :action_time=>0.00105}
|
277
|
+
~ cache: miss (/cache_controller/action4/path/to/nowhere)
|
278
|
+
~ cache: miss (/cache_controller/action4/path/to/nowhere)
|
279
|
+
~ cache: miss (/cache_controller/action4)
|
280
|
+
~ cache: set (/cache_controller/action4)
|
281
|
+
~ {:after_filters_time=>0.002476, :before_filters_time=>0.000364, :action_time=>0.002862}
|
282
|
+
~ cache: expired (/cache_controller/action4)
|
283
|
+
~ cache: miss (/cache_controller/action4)
|
284
|
+
~ cache: miss (/cache_controller/action4)
|
285
|
+
~ cache: set (/cache_controller/action4)
|
286
|
+
~ {:after_filters_time=>0.000716, :before_filters_time=>0.000307, :action_time=>0.00104}
|
287
|
+
~ cache: expired (/cache_controller/action4/path/to/nowhere)
|
288
|
+
~ cache: expired (/cache_controller/action4)
|
289
|
+
~ cache: miss (/cache_controller/action4)
|
290
|
+
~ cache: miss (/cache_controller/action4)
|
291
|
+
~ cache: set (/cache_controller/action4)
|
292
|
+
~ {:after_filters_time=>0.000476, :before_filters_time=>0.000189, :action_time=>0.000675}
|
293
|
+
~ cache: expired (/cache_controller/action4)
|
294
|
+
~ cache: miss (/cache_controller/action4)
|
295
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
296
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
297
|
+
~ {:after_filters_time=>0.000473, :before_filters_time=>0.000189, :action_time=>0.000671}
|
298
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
299
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
300
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
301
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
302
|
+
~ {:after_filters_time=>0.000486, :before_filters_time=>0.000181, :action_time=>0.000678}
|
303
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
304
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
305
|
+
~ cache: miss (/cache_controller/action4)
|
306
|
+
~ cache: set (/cache_controller/action4)
|
307
|
+
~ {:after_filters_time=>0.000484, :before_filters_time=>0.00019, :action_time=>0.000683}
|
308
|
+
~ cache: expired (/cache_controller/action4)
|
309
|
+
~ cache: miss (/cache_controller/action4)
|
310
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
311
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
312
|
+
~ {:after_filters_time=>0.000487, :before_filters_time=>0.000182, :action_time=>0.000679}
|
313
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
314
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
315
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
316
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
317
|
+
~ {:after_filters_time=>0.000471, :before_filters_time=>0.000187, :action_time=>0.000668}
|
318
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
319
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
320
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
321
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
322
|
+
~ {:after_filters_time=>0.000475, :before_filters_time=>0.000195, :action_time=>0.00068}
|
323
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
324
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
325
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
326
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
327
|
+
~ {:after_filters_time=>0.000489, :before_filters_time=>0.000174, :action_time=>0.000671}
|
328
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
329
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
330
|
+
~ cache: miss (/cache_controller/action4)
|
331
|
+
~ cache: set (/cache_controller/action4)
|
332
|
+
~ {:after_filters_time=>0.000485, :before_filters_time=>0.000199, :action_time=>0.000694}
|
333
|
+
~ cache: expired (/cache_controller/action4)
|
334
|
+
~ cache: miss (/cache_controller/action4)
|
335
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
336
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
337
|
+
~ {:after_filters_time=>0.000474, :before_filters_time=>0.000189, :action_time=>0.000673}
|
338
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
339
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
340
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
341
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
342
|
+
~ {:after_filters_time=>0.000471, :before_filters_time=>0.000186, :action_time=>0.000667}
|
343
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
344
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
345
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
346
|
+
~ cache: set (/cache_controller/action4/id1/id2)
|
347
|
+
~ {:after_filters_time=>0.000486, :before_filters_time=>0.00019, :action_time=>0.000686}
|
348
|
+
~ cache: expired (/cache_controller/action4/id1/id2)
|
349
|
+
~ cache: miss (/cache_controller/action4/id1/id2)
|
350
|
+
~ {:after_filters_time=>2.6e-05, :before_filters_time=>0.000162, :action_time=>0.000202}
|
351
|
+
~ cache: miss (/cache_controller/action8)
|
352
|
+
~ cache: miss (/cache_controller/action8/cache)
|
353
|
+
~ cache: set (/cache_controller/action8/cache)
|
354
|
+
~ {:after_filters_time=>0.000484, :before_filters_time=>0.000266, :action_time=>0.000759}
|
355
|
+
~ {:after_filters_time=>2.6e-05, :before_filters_time=>0.000107, :action_time=>0.000143}
|
356
|
+
~ cache: miss (/cache_controller/action9)
|
357
|
+
~ cache: miss (/cache_controller/action9/cache)
|
358
|
+
~ cache: set (/cache_controller/action9/cache)
|
359
|
+
~ {:after_filters_time=>0.000502, :before_filters_time=>0.000276, :action_time=>0.000788}
|
360
|
+
~ {:after_filters_time=>2.5e-05, :before_filters_time=>0.000147, :action_time=>0.000182}
|
361
|
+
~ cache: miss (/cache_controller/action10)
|
362
|
+
~ cache: miss (/cache_controller/action10/cache)
|
363
|
+
~ cache: set (/cache_controller/action10/cache)
|
364
|
+
~ {:after_filters_time=>0.003832, :before_filters_time=>0.000274, :action_time=>0.004122}
|
365
|
+
~ {:after_filters_time=>3.2e-05, :before_filters_time=>0.000154, :action_time=>0.000203}
|
366
|
+
~ cache: miss (/cache_controller/action11)
|
367
|
+
~ cache: miss (/cache_controller/action11/cache)
|
368
|
+
~ cache: set (/cache_controller/action11/cache)
|
369
|
+
~ {:after_filters_time=>0.000503, :before_filters_time=>0.000397, :action_time=>0.000915}
|
370
|
+
~ cache: set (/cache_controller/action5)
|
371
|
+
~ {:after_filters_time=>0.000436, :before_filters_time=>0.000189, :action_time=>0.000647}
|
372
|
+
~ cache: set (/cache_controller/action5/this/is/a/test)
|
373
|
+
~ {:after_filters_time=>0.001277, :before_filters_time=>0.000256, :action_time=>0.001557}
|
374
|
+
~ cache: set (/cache_controller/action6)
|
375
|
+
~ {:after_filters_time=>0.000479, :before_filters_time=>0.000253, :action_time=>0.00077}
|
376
|
+
~ cache: hit (/cache_controller/action6)
|
377
|
+
~ {:after_filters_time=>3.8e-05, :action_time=>0.000645}
|
378
|
+
~ cache: set (/cache_controller/action6)
|
379
|
+
~ {:after_filters_time=>0.00062, :before_filters_time=>0.000919, :action_time=>0.001593}
|
380
|
+
~ cache: set (/cache_controller/action6/path/to/nowhere)
|
381
|
+
~ {:after_filters_time=>0.001441, :before_filters_time=>0.000285, :action_time=>0.001775}
|
382
|
+
~ cache: hit (/cache_controller/action6/path/to/nowhere)
|
383
|
+
~ {:after_filters_time=>3.8e-05, :action_time=>0.000643}
|
384
|
+
~ cache: set (/cache_controller/action6/path/to/nowhere)
|
385
|
+
~ {:after_filters_time=>0.000637, :before_filters_time=>0.000806, :action_time=>0.001497}
|
386
|
+
~ cache: set (/cache_controller/action6)
|
387
|
+
~ {:after_filters_time=>0.000548, :before_filters_time=>0.000235, :action_time=>0.000817}
|
388
|
+
~ cache: set (/cache_controller/action6)
|
389
|
+
~ {:after_filters_time=>0.00057, :before_filters_time=>0.000325, :action_time=>0.000951}
|
390
|
+
~ cache: set (/cache_controller/action6)
|
391
|
+
~ {:after_filters_time=>0.00043, :before_filters_time=>0.000217, :action_time=>0.000679}
|
392
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
393
|
+
~ {:after_filters_time=>0.001216, :before_filters_time=>0.000286, :action_time=>0.00153}
|
394
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
395
|
+
~ {:after_filters_time=>0.000472, :before_filters_time=>0.000228, :action_time=>0.000734}
|
396
|
+
~ cache: set (/cache_controller/action6)
|
397
|
+
~ {:after_filters_time=>0.000451, :before_filters_time=>0.000232, :action_time=>0.000713}
|
398
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
399
|
+
~ {:after_filters_time=>0.000982, :before_filters_time=>0.000246, :action_time=>0.001256}
|
400
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
401
|
+
~ {:after_filters_time=>0.000375, :before_filters_time=>0.000203, :action_time=>0.000604}
|
402
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
403
|
+
~ {:after_filters_time=>0.000868, :before_filters_time=>0.000203, :action_time=>0.001096}
|
404
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
405
|
+
~ {:after_filters_time=>0.000316, :before_filters_time=>0.000188, :action_time=>0.000527}
|
406
|
+
~ cache: set (/cache_controller/action6)
|
407
|
+
~ {:after_filters_time=>0.000301, :before_filters_time=>0.000264, :action_time=>0.000584}
|
408
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
409
|
+
~ {:after_filters_time=>0.000284, :before_filters_time=>0.000184, :action_time=>0.000487}
|
410
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
411
|
+
~ {:after_filters_time=>0.000294, :before_filters_time=>0.00013, :action_time=>0.000444}
|
412
|
+
~ cache: set (/cache_controller/action6/id1/id2)
|
413
|
+
~ {:after_filters_time=>0.000653, :before_filters_time=>0.000335, :action_time=>0.001034}
|
414
|
+
~ cache: set (/cache_controller/action7.css)
|
415
|
+
~ {:after_filters_time=>0.000679, :before_filters_time=>0.000226, :action_time=>0.000941}
|
416
|
+
~ cache: hit (/cache_controller/action7.css)
|
417
|
+
~ {:after_filters_time=>2.5e-05, :action_time=>0.000364}
|
418
|
+
~ cache: set (/cache_controller/action7.js)
|
419
|
+
~ {:after_filters_time=>0.000474, :before_filters_time=>0.000188, :action_time=>0.000696}
|
420
|
+
~ cache: hit (/cache_controller/action7.js)
|
421
|
+
~ {:after_filters_time=>2.0e-05, :action_time=>0.000274}
|
422
|
+
~ cache: set (/cache_controller/action7.xml)
|
423
|
+
~ {:after_filters_time=>0.000548, :before_filters_time=>0.000168, :action_time=>0.000902}
|
424
|
+
~ cache: hit (/cache_controller/action7.xml)
|
425
|
+
~ {:after_filters_time=>2.1e-05, :action_time=>0.000298}
|
426
|
+
~ cache: set (/cache_controller/action7.jpg)
|
427
|
+
~ {:after_filters_time=>0.000318, :before_filters_time=>0.000162, :action_time=>0.000504}
|
428
|
+
~ cache: hit (/cache_controller/action7.jpg)
|
429
|
+
~ {:after_filters_time=>1.9e-05, :action_time=>0.000241}
|
430
|
+
~ cache: set (/cache_controller/action7.html)
|
431
|
+
~ {:after_filters_time=>0.000294, :before_filters_time=>0.000153, :action_time=>0.000467}
|
432
|
+
~ cache: hit (/cache_controller/action7.html)
|
433
|
+
~ {:after_filters_time=>2.0e-05, :action_time=>0.000239}
|
@@ -103,4 +103,60 @@ describe "merb-cache-action" do
|
|
103
103
|
CACHE.cached_action?(:key => "/cache_controller/action4/id1/id2").should be_false
|
104
104
|
end
|
105
105
|
|
106
|
+
it "should allow :if conditions with procs" do
|
107
|
+
c = get("/cache_controller/action8")
|
108
|
+
CACHE.cached_action?(:key => "/cache_controller/action8").should be_false
|
109
|
+
|
110
|
+
c = get("/cache_controller/action8/cache")
|
111
|
+
CACHE.cached_action?(:key => "/cache_controller/action8/cache").should be_true
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should allow :unless conditions with procs" do
|
115
|
+
c = get("/cache_controller/action9")
|
116
|
+
CACHE.cached_action?(:key => "/cache_controller/action9").should be_false
|
117
|
+
|
118
|
+
c = get("/cache_controller/action9/cache")
|
119
|
+
CACHE.cached_action?(:key => "/cache_controller/action9/cache").should be_true
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should allow :if conditions with symbols" do
|
123
|
+
c = get("/cache_controller/action10")
|
124
|
+
CACHE.cached_action?(:key => "/cache_controller/action10").should be_false
|
125
|
+
|
126
|
+
c = get("/cache_controller/action10/cache")
|
127
|
+
CACHE.cached_action?(:key => "/cache_controller/action10/cache").should be_true
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should allow :unless conditions with symbols" do
|
131
|
+
c = get("/cache_controller/action11")
|
132
|
+
CACHE.cached_action?(:key => "/cache_controller/action11").should be_false
|
133
|
+
|
134
|
+
c = get("/cache_controller/action11/cache")
|
135
|
+
CACHE.cached_action?(:key => "/cache_controller/action11/cache").should be_true
|
136
|
+
end
|
106
137
|
end
|
138
|
+
|
139
|
+
describe "merb-cache-actions" do
|
140
|
+
it "should cache multiple actions passed as arguments to it (cache_actions_1, cache_actions_2, cache_actions_3)" do
|
141
|
+
c = get("/cache_controller/cache_actions_1")
|
142
|
+
c.body.strip.should == "test cache_actions_1"
|
143
|
+
c.cached?("/cache_controller/cache_actions_1").should be_true
|
144
|
+
c.cached_action?("cache_actions_1").should be_true
|
145
|
+
c.cache_get("/cache_controller/cache_actions_1").should == "test cache_actions_1"
|
146
|
+
|
147
|
+
c = get("/cache_controller/cache_actions_2")
|
148
|
+
c.body.strip.should == "test cache_actions_2"
|
149
|
+
c.cached?("/cache_controller/cache_actions_2").should be_true
|
150
|
+
c.cached_action?("cache_actions_2").should be_true
|
151
|
+
c.cache_get("/cache_controller/cache_actions_2").should == "test cache_actions_2"
|
152
|
+
sleep 4
|
153
|
+
c.cache_get("/cache_controller/cache_actions_2").should be_nil
|
154
|
+
c.cached_action?(:action => "cache_actions_2").should be_false
|
155
|
+
|
156
|
+
c = get("/cache_controller/cache_actions_3")
|
157
|
+
CACHE.cached_action?(:key => "/cache_controller/cache_actions_3").should be_true
|
158
|
+
|
159
|
+
c = get("/cache_controller/cache_actions_3/cache")
|
160
|
+
CACHE.cached_action?(:key => "/cache_controller/cache_actions_3/cache").should be_false
|
161
|
+
end
|
162
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,7 @@ def use_cache_store(store, orm = nil)
|
|
20
20
|
:store => store,
|
21
21
|
:cache_directory => File.dirname(__FILE__) / "tmp/cache",
|
22
22
|
:cache_html_directory => File.dirname(__FILE__) / "tmp/html",
|
23
|
+
:no_tracking => false
|
23
24
|
}
|
24
25
|
FileUtils.rm_rf(Dir.glob(File.dirname(__FILE__) / "/tmp"))
|
25
26
|
case store
|
metadata
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Boussinet
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-13 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: merb-core
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
20
21
|
- - ">="
|
21
22
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.9.
|
23
|
+
version: 0.9.4
|
23
24
|
version:
|
24
25
|
description: Merb plugin that provides caching (page, action, fragment, object)
|
25
26
|
email: alex.boussinet@gmail.com
|
@@ -55,6 +56,8 @@ files:
|
|
55
56
|
- spec/config
|
56
57
|
- spec/config/database.yml
|
57
58
|
- spec/controller.rb
|
59
|
+
- spec/log
|
60
|
+
- spec/log/merb_test.log
|
58
61
|
- spec/merb-cache-action_spec.rb
|
59
62
|
- spec/merb-cache-fragment_spec.rb
|
60
63
|
- spec/merb-cache-page_spec.rb
|
@@ -65,7 +68,7 @@ files:
|
|
65
68
|
- spec/views/cache_controller/action1.html.erb
|
66
69
|
- spec/views/cache_controller/action2.html.haml
|
67
70
|
has_rdoc: true
|
68
|
-
homepage: http://
|
71
|
+
homepage: http://merbivore.com
|
69
72
|
post_install_message:
|
70
73
|
rdoc_options: []
|
71
74
|
|
@@ -85,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
88
|
version:
|
86
89
|
requirements: []
|
87
90
|
|
88
|
-
rubyforge_project:
|
89
|
-
rubygems_version: 1.0
|
91
|
+
rubyforge_project: merb
|
92
|
+
rubygems_version: 1.2.0
|
90
93
|
signing_key:
|
91
94
|
specification_version: 2
|
92
95
|
summary: Merb plugin that provides caching (page, action, fragment, object)
|