padrino-cache 0.11.4 → 0.12.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 374334fdc24a2ded02fce9d03b21176bcb9692b8
4
- data.tar.gz: d6d07f4a86e8d5ecbd0fc53654dc328b9240d166
3
+ metadata.gz: 638e5c5671b96bfdddd92ec93bf3883209c47461
4
+ data.tar.gz: 6d4bbaed06c182dcfc7357078e24db6264c2b001
5
5
  SHA512:
6
- metadata.gz: 9d550329256cbf42946e0205fa4edd5670ee01873d9291f0ba5dff6ae77969f712152d3247a2bfdd5e1ce725f94395741c34ef358a08ae61752d8381c806da75
7
- data.tar.gz: e9c536170da6ef7e61bcbaf77c6b6acebb13844a7713ab2a4f54652fa38f9c06bcc2df96f02477b31dac6e8225844d8ede8ac754905644483499da18f6628187
6
+ metadata.gz: 149147b7332bc70ac260cb4c5e75691262f71f6526cbe3d98361d421fc01df118328f844281a67faea933eab099621f1e0d1b68a5f5367a5a3bcfa23c1d14d7e
7
+ data.tar.gz: 2b6840b7d90f6cb19405b8bfb250b6595a1fb927cbcdf4c0a8142d190c3c05df8cdb6393ebfe32436b8d5b7c17c049d329e4dc62f8e5fd336ec2c8f0a5607619
data/README.rdoc CHANGED
@@ -5,7 +5,8 @@
5
5
  This component enables caching of an application's response contents on
6
6
  both page- and fragment-levels. Output cached in this manner is
7
7
  persisted, until it expires or is actively expired, in a configurable store
8
- of your choosing. Several common caching stores are supported out of the box.
8
+ of your choosing. Most popular key/value stores work out of the box. Take a look
9
+ at the [Moneta documentation](http://rubydoc.info/gems/moneta) for a list of all supported stores.
9
10
 
10
11
  == Caching Quickstart
11
12
 
@@ -26,7 +27,7 @@ your needs, you can enable it very easily:
26
27
  enable :caching
27
28
 
28
29
  get '/foo', :cache => true do
29
- expires_in 30 # expire cached version at least every 30 seconds
30
+ expires 30 # expire cached version at least every 30 seconds
30
31
  'Hello world'
31
32
  end
32
33
  end
@@ -44,7 +45,7 @@ You can also cache on a controller-wide basis:
44
45
 
45
46
  # Requests to routes within '/admin'
46
47
  controller '/admin', :cache => true do
47
- expires_in 60
48
+ expires 60
48
49
 
49
50
  get '/foo' do
50
51
  'Url is /admin/foo'
@@ -75,9 +76,9 @@ You can also provide a custom <tt>cache_key</tt> in any route:
75
76
  In this way you can manually expire cache with CachedApp.cache.delete(:my_name)
76
77
  for example from the Post model after an update.
77
78
 
78
- If you specify <tt>:cache => true</tt> but do not invoke <tt>expires_in</tt>,
79
+ If you specify <tt>:cache => true</tt> but do not invoke <tt>expires</tt>,
79
80
  the response will be cached indefinitely. Most of the time, you will want to
80
- specify the expiry of a cache entry by <tt>expires_in</tt>. Even a relatively
81
+ specify the expiry of a cache entry by <tt>expires</tt>. Even a relatively
81
82
  low value--1 or 2 seconds--can greatly increase application efficiency, especially
82
83
  when enabled on a very active part of your domain.
83
84
 
@@ -110,7 +111,7 @@ easy to integrate into your application. To turn it on, simply provide the
110
111
  By default, cached content is persisted with a "file store"--that is, in a
111
112
  subdirectory of your application root.
112
113
 
113
- ==== <tt>expires_in( seconds )</tt>
114
+ ==== <tt>expires( seconds )</tt>
114
115
 
115
116
  This helper is used within a controller or route to indicate how often cached
116
117
  <em>page-level</em> content should persist in the cache.
@@ -126,7 +127,7 @@ be executed; rather, its previous output will be sent to the client with a
126
127
  enable :caching # turns on caching
127
128
 
128
129
  controller '/blog', :cache => true do
129
- expires_in 15
130
+ expires 15
130
131
 
131
132
  get '/entries' do
132
133
  'just broke up eating twinkies lol'
@@ -134,7 +135,7 @@ be executed; rather, its previous output will be sent to the client with a
134
135
  end
135
136
  end
136
137
 
137
- Note that the "latest" method call to <tt>expires_in</tt> determines its value: if
138
+ Note that the "latest" method call to <tt>expires</tt> determines its value: if
138
139
  called within a route, as opposed to a controller definition, the route's
139
140
  value will be assumed.
140
141
 
@@ -165,7 +166,7 @@ to be cached. It can be used in within a route:
165
166
  get :feed, :map => '/:username' do
166
167
  username = params[:username]
167
168
 
168
- @feed = cache( "feed_for_#{username}", :expires_in => 3 ) do
169
+ @feed = cache( "feed_for_#{username}", :expires => 3 ) do
169
170
  @tweets = Tweet.all( :username => username )
170
171
  render 'partials/feedcontent'
171
172
  end
@@ -192,7 +193,7 @@ Note that any other action will reference the same content if it uses the same k
192
193
  get :feed, :map => '/:username' do
193
194
  username = params[:username]
194
195
 
195
- @feed = cache( "feed_for_#{username}", :expires_in => 3 ) do
196
+ @feed = cache( "feed_for_#{username}", :expires => 3 ) do
196
197
  @tweets = Tweet.all( :username => username )
197
198
  render 'partials/feedcontent'
198
199
  end
@@ -204,7 +205,7 @@ Note that any other action will reference the same content if it uses the same k
204
205
  get :mobile_feed, :map => '/:username.iphone' do
205
206
  username = params[:username]
206
207
 
207
- @feed = cache( "feed_for_#{username}", :expires_in => 3 ) do
208
+ @feed = cache( "feed_for_#{username}", :expires => 3 ) do
208
209
  @tweets = Tweet.all( :username => username )
209
210
  render 'partials/feedcontent'
210
211
  end
@@ -214,7 +215,8 @@ Note that any other action will reference the same content if it uses the same k
214
215
  end
215
216
  end
216
217
 
217
- The <tt>opts</tt> argument is actually passed to the underlying store. All stores included with Padrino support the <tt>:expires_in</tt> option out of the box.
218
+ The <tt>opts</tt> argument is actually passed to the underlying store. The stores support the <tt>:expires</tt> option out of the box or
219
+ are enhanced by Moneta to support it.
218
220
 
219
221
  Finally, to DRY up things a bit, we might do:
220
222
 
@@ -226,7 +228,7 @@ Finally, to DRY up things a bit, we might do:
226
228
  controller :tweets do
227
229
  # This works because all routes in this controller specify :username
228
230
  before do
229
- @feed = cache( "feed_for_#{params[:username]}", :expires_in => 3 ) do
231
+ @feed = cache( "feed_for_#{params[:username]}", :expires => 3 ) do
230
232
  @tweets = Tweet.all( :username => params[:username] )
231
233
  render 'partials/feedcontent'
232
234
  end
@@ -253,35 +255,40 @@ You can set a global caching option or a per app caching options.
253
255
 
254
256
  === Global Caching Options
255
257
 
256
- Padrino.cache = Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1))
257
- Padrino.cache = Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1))
258
- Padrino.cache = Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new(...)
259
- Padrino.cache = Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
260
- Padrino.cache = Padrino::Cache::Store::Memory.new(50)
261
- Padrino.cache = Padrino::Cache::Store::File.new(/my/cache/path)
258
+ Padrino.cache = Padrino::Cache.new(:LRUHash) # Keeps cached values in memory
259
+ Padrino.cache = Padrino::Cache.new(:Memcached) # Uses default server at localhost
260
+ Padrino.cache = Padrino::Cache.new(:Memcached, '127.0.0.1:11211', :exception_retry_limit => 1)
261
+ Padrino.cache = Padrino::Cache.new(:Memcached, :backend => memcached_or_dalli_instance)
262
+ Padrino.cache = Padrino::Cache.new(:Redis) # Uses default server at localhost
263
+ Padrino.cache = Padrino::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0)
264
+ Padrino.cache = Padrino::Cache.new(:Redis, :backend => redis_instance)
265
+ Padrino.cache = Padrino::Cache.new(:Mongo) # Uses default server at localhost
266
+ Padrino.cache = Padrino::Cache.new(:Mongo, :backend => mongo_client_instance)
267
+ Padrino.cache = Padrino::Cache.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache')) # default choice
262
268
 
263
269
  You can manage your cache from anywhere in your app:
264
270
 
265
- Padrino.cache.set('val', 'test')
266
- Padrino.cache.get('val') # => 'test'
271
+ Padrino.cache['val'] = 'test'
272
+ Padrino.cache['val'] # => 'test'
267
273
  Padrino.cache.delete('val')
268
- Padrino.cache.flush
274
+ Padrino.cache.clear
275
+
276
+ The Padrino cache constructor `Padrino::Cache.new` calls `Moneta.new` to create a cache instance. Please refer to the [Moneta documentation](http://rubydoc.info/gems/moneta) if you
277
+ have special requirements, for example if you want to configure the marshalling mechanism or use a more exotic backend.
269
278
 
270
279
  ==== Application Caching Options
271
280
 
272
- set :cache, Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1))
273
- set :cache, Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1))
274
- set :cache, Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
275
- set :cache, Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new(...))
276
- set :cache, Padrino::Cache::Store::Memory.new(50)
277
- set :cache, Padrino::Cache::Store::File.new(Padrino.root('tmp', app_name, 'cache') # default choice
281
+ set :cache, Padrino::Cache.new(:LRUHash)
282
+ set :cache, Padrino::Cache.new(:Memcached)
283
+ set :cache, Padrino::Cache.new(:Redis)
284
+ set :cache, Padrino::Cache.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache')) # default choice
278
285
 
279
286
  You can manage your cache from anywhere in your app:
280
287
 
281
- MyApp.cache.set('val', 'test')
282
- MyApp.cache.get('val') # => 'test'
288
+ MyApp.cache['val'] = 'test'
289
+ MyApp.cache['val'] # => 'test'
283
290
  MyApp.cache.delete('val')
284
- MyApp.cache.flush
291
+ MyApp.cache.clear
285
292
 
286
293
  == Expiring Cached Content
287
294
 
@@ -316,7 +323,7 @@ do our user a favor and instantly re-render the feed.
316
323
  expire( "feed since #{last_visit}" ) if @tweets.any? { |t| t.deleted_since?( last_visit ) }
317
324
 
318
325
  session[:last_visit] = Time.now
319
- @feed = cache( "feed since #{last_visit}", :expires_in => 60 ) do
326
+ @feed = cache( "feed since #{last_visit}", :expires => 60 ) do
320
327
  @tweets = @tweets.find_all { |t| !t.deleted? }
321
328
  render 'partials/feedcontent'
322
329
  end
data/lib/padrino-cache.rb CHANGED
@@ -2,6 +2,8 @@ require 'fileutils' unless defined?(FileUtils)
2
2
  require 'padrino-core'
3
3
  require 'padrino-helpers'
4
4
  FileSet.glob_require('padrino-cache/{helpers}/*.rb', __FILE__)
5
+ require 'moneta'
6
+ require 'padrino-cache/legacy_store'
5
7
 
6
8
  module Padrino
7
9
  class << self
@@ -9,11 +11,11 @@ module Padrino
9
11
  # Returns the caching engine.
10
12
  #
11
13
  # @example
12
- # # with: Padrino.cache = Padrino::Cache::Store::File.new(/my/cache/path)
13
- # Padrino.cache.set('val', 'test')
14
- # Padrino.cache.get('val') # => 'test'
14
+ # # with: Padrino.cache = Padrino::Cache.new(:File, :dir => /my/cache/path)
15
+ # Padrino.cache['val'] = 'test'
16
+ # Padrino.cache['val'] # => 'test'
15
17
  # Padrino.cache.delete('val')
16
- # Padrino.cache.flush
18
+ # Padrino.cache.clear
17
19
  #
18
20
  def cache
19
21
  @_cache
@@ -23,22 +25,26 @@ module Padrino
23
25
  # Set the caching engine.
24
26
  #
25
27
  # @param value
26
- # Instance of Padrino::Cache::Store
28
+ # Instance of Moneta store
27
29
  #
28
30
  # @example
29
- # Padrino.cache = Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1))
30
- # Padrino.cache = Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1))
31
- # Padrino.cache = Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
32
- # Padrino.cache = Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new('127.0.0.1', 27017).db('padrino'), :username => 'username', :password => 'password', :size => 64, :max => 100, :collection => 'cache')
33
- # Padrino.cache = Padrino::Cache::Store::Memory.new(50)
34
- # Padrino.cache = Padrino::Cache::Store::File.new(/my/cache/path)
31
+ # Padrino.cache = Padrino::Cache.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache')) # default choice
32
+ # Padrino.cache = Padrino::Cache.new(:LRUHash) # Keeps cached values in memory
33
+ # Padrino.cache = Padrino::Cache.new(:Memcached) # Uses default server at localhost
34
+ # Padrino.cache = Padrino::Cache.new(:Memcached, '127.0.0.1:11211', :exception_retry_limit => 1)
35
+ # Padrino.cache = Padrino::Cache.new(:Memcached, :backend => memcached_or_dalli_instance)
36
+ # Padrino.cache = Padrino::Cache.new(:Redis) # Uses default server at localhost
37
+ # Padrino.cache = Padrino::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0)
38
+ # Padrino.cache = Padrino::Cache.new(:Redis, :backend => redis_instance)
39
+ # Padrino.cache = Padrino::Cache.new(:Mongo) # Uses default server at localhost
40
+ # Padrino.cache = Padrino::Cache.new(:Mongo, :backend => mongo_client_instance)
35
41
  #
36
42
  # # You can manage your cache from anywhere in your app:
37
43
  #
38
- # Padrino.cache.set('val', 'test')
39
- # Padrino.cache.get('val') # => 'test'
44
+ # Padrino.cache['val'] = 'test'
45
+ # Padrino.cache['val'] # => 'test'
40
46
  # Padrino.cache.delete('val')
41
- # Padrino.cache.flush
47
+ # Padrino.cache.clear
42
48
  #
43
49
  def cache=(value)
44
50
  @_cache= value
@@ -52,9 +58,6 @@ module Padrino
52
58
  # of your choosing. Several common caching stores are supported out of the box.
53
59
  #
54
60
  module Cache
55
- autoload :Store, 'padrino-cache/store'
56
- autoload :Parser, 'padrino-cache/parser'
57
-
58
61
  class << self
59
62
  ##
60
63
  # Register these helpers:
@@ -67,29 +70,34 @@ module Padrino
67
70
  #
68
71
  # By default we use FileStore as showed below:
69
72
  #
70
- # set :cache, Padrino::Cache::Store::File.new(File.join(app.root, 'tmp', 'cache'))
73
+ # set :cache, Padrino::Cache.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache'))
71
74
  #
72
75
  # However, you can also change the file store easily in your app.rb:
73
76
  #
74
- # set :cache, Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1))
75
- # set :cache, Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1))
76
- # set :cache, Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
77
- # set :cache, Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new('127.0.0.1', 27017).db('padrino'), :username => 'username', :password => 'password', :size => 64, :max => 100, :collection => 'cache')
78
- # set :cache, Padrino::Cache::Store::Memory.new(50)
79
- # set :cache, Padrino::Cache::Store::File.new(Padrino.root('tmp', app_name.to_s, 'cache')) # default choice
77
+ # set :cache, Padrino::Cache.new(:LRUHash) # Keeps cached values in memory
78
+ # set :cache, Padrino::Cache.new(:Memcached) # Uses default server at localhost
79
+ # set :cache, Padrino::Cache.new(:Memcached, '127.0.0.1:11211', :exception_retry_limit => 1)
80
+ # set :cache, Padrino::Cache.new(:Memcached, :backend => memcached_or_dalli_instance)
81
+ # set :cache, Padrino::Cache.new(:Redis) # Uses default server at localhost
82
+ # set :cache, Padrino::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0)
83
+ # set :cache, Padrino::Cache.new(:Redis, :backend => redis_instance)
84
+ # set :cache, Padrino::Cache.new(:Mongo) # Uses default server at localhost
85
+ # set :cache, Padrino::Cache.new(:Mongo, :backend => mongo_client_instance)
86
+ # set :cache, Padrino::Cache.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache')) # default choice
80
87
  #
81
88
  # You can manage your cache from anywhere in your app:
82
89
  #
83
- # MyApp.cache.set('val', 'test')
84
- # MyApp.cache.get('val') # => 'test'
90
+ # MyApp.cache['val'] = 'test'
91
+ # MyApp.cache['val'] # => 'test'
85
92
  # MyApp.cache.delete('val')
86
- # MyApp.cache.flush
93
+ # MyApp.cache.clear
87
94
  #
88
95
  def registered(app)
89
96
  app.helpers Padrino::Cache::Helpers::CacheStore
90
97
  app.helpers Padrino::Cache::Helpers::Fragment
91
98
  app.helpers Padrino::Cache::Helpers::Page
92
- app.set :cache, Padrino::Cache::Store::File.new(Padrino.root('tmp', defined?(app.app_name) ? app.app_name.to_s : '', 'cache'))
99
+ app.set :cache, Padrino::Cache.new(:File,
100
+ :dir => Padrino.root('tmp', defined?(app.app_name) ? app.app_name.to_s : '', 'cache'))
93
101
  app.disable :caching
94
102
  end
95
103
  alias :included :registered
@@ -99,6 +107,17 @@ module Padrino
99
107
  end
100
108
  end
101
109
 
102
- Padrino.cache = Store::Memory.new(50)
110
+ def self.new(name, options = {})
111
+ # Activate expiration by default
112
+ options[:expires] = true unless options.include?(:expires)
113
+ a = Moneta.new(name, options)
114
+ Moneta.build do
115
+ # Use proxy to support deprecated Padrino interface
116
+ use LegacyStore
117
+ adapter a
118
+ end
119
+ end
120
+
121
+ Padrino.cache = Padrino::Cache.new(:LRUHash)
103
122
  end
104
123
  end
@@ -8,6 +8,7 @@ module Padrino
8
8
  else
9
9
  settings.cache.delete(self.class.url(*key))
10
10
  end
11
+ nil
11
12
  end
12
13
  end
13
14
  end
@@ -23,7 +23,7 @@ module Padrino
23
23
  # @param [String] key
24
24
  # cache key
25
25
  # @param [Hash] opts
26
- # cache options, e.g :expires_in
26
+ # cache options, e.g :expires
27
27
  # @param [Proc]
28
28
  # Execution result to store in the cache
29
29
  #
@@ -36,7 +36,7 @@ module Padrino
36
36
  # get :feed, :map => '/:username' do
37
37
  # username = params[:username]
38
38
  #
39
- # @feed = cache( "feed_for_#{username}", :expires_in => 3 ) do
39
+ # @feed = cache( "feed_for_#{username}", :expires => 3 ) do
40
40
  # @tweets = Tweet.all( :username => username )
41
41
  # render 'partials/feedcontent'
42
42
  # end
@@ -47,15 +47,16 @@ module Padrino
47
47
  # end
48
48
  # end
49
49
  #
50
- def cache(key, opts = nil, &block)
50
+ # @api public
51
+ def cache(key, opts = {}, &block)
51
52
  if settings.caching?
52
53
  began_at = Time.now
53
- if value = settings.cache.get(key.to_s)
54
+ if value = settings.cache[key.to_s]
54
55
  logger.debug "GET Fragment", began_at, key.to_s if defined?(logger)
55
56
  concat_content(value.html_safe)
56
57
  else
57
58
  value = capture_html(&block)
58
- settings.cache.set(key.to_s, value, opts)
59
+ settings.cache.store(key.to_s, value, opts)
59
60
  logger.debug "SET Fragment", began_at, key.to_s if defined?(logger)
60
61
  concat_content(value)
61
62
  end
@@ -16,10 +16,10 @@ module Padrino
16
16
  # enable :caching # turns on caching mechanism
17
17
  #
18
18
  # controller '/blog', :cache => true do
19
- # expires_in 15
19
+ # expires 15
20
20
  #
21
21
  # get '/entries' do
22
- # # expires_in 15 => can also be defined inside a single route
22
+ # # expires 15 => can also be defined inside a single route
23
23
  # 'Just broke up eating twinkies, lol'
24
24
  # end
25
25
  #
@@ -32,7 +32,7 @@ module Padrino
32
32
  #
33
33
  # You can manually expire cache with CachedApp.cache.delete(:my_name)
34
34
  #
35
- # Note that the "latest" method call to <tt>expires_in</tt> determines its value: if
35
+ # Note that the "latest" method call to <tt>expires</tt> determines its value: if
36
36
  # called within a route, as opposed to a controller definition, the route's
37
37
  # value will be assumed.
38
38
  #
@@ -51,17 +51,22 @@ module Padrino
51
51
  #
52
52
  # @example
53
53
  # controller '/blog', :cache => true do
54
- # expires_in 15
54
+ # expires 15
55
55
  #
56
56
  # get '/entries' do
57
- # # expires_in 15 => can also be defined inside a single route
58
57
  # 'Just broke up eating twinkies, lol'
59
58
  # end
60
59
  # end
61
60
  #
61
+ # @api public
62
+ def expires(time)
63
+ @route.cache_expires = time if @route
64
+ @_last_expires = time
65
+ end
66
+
62
67
  def expires_in(time)
63
- @route.cache_expires_in = time if @route
64
- @_last_expires_in = time
68
+ warn 'expires_in has been deprecated in favour of expires'
69
+ expires(time)
65
70
  end
66
71
 
67
72
  ##
@@ -99,10 +104,13 @@ module Padrino
99
104
  if settings.caching?
100
105
  began_at = Time.now
101
106
 
102
- value = settings.cache.get(resolve_cache_key || env['PATH_INFO'])
107
+ value = settings.cache[resolve_cache_key || env['PATH_INFO']]
103
108
  logger.debug "GET Cache", began_at, @route.cache_key || env['PATH_INFO'] if defined?(logger) && value
104
109
 
105
- if value
110
+ if value.kind_of?(Hash)
111
+ content_type value[:content_type]
112
+ halt 200, value[:body]
113
+ elsif value
106
114
  halt 200, value
107
115
  end
108
116
  end
@@ -111,13 +119,16 @@ module Padrino
111
119
  route.after_filters do
112
120
  if settings.caching? && @_response_buffer.kind_of?(String)
113
121
  began_at = Time.now
114
- content = @_response_buffer
122
+ content = {
123
+ :body => @_response_buffer,
124
+ :content_type => @_content_type
125
+ }
115
126
 
116
- if @_last_expires_in
117
- settings.cache.set(resolve_cache_key || env['PATH_INFO'], content, :expires_in => @_last_expires_in)
118
- @_last_expires_in = nil
127
+ if @_last_expires
128
+ settings.cache.store(resolve_cache_key || env['PATH_INFO'], content, :expires => @_last_expires)
129
+ @_last_expires = nil
119
130
  else
120
- settings.cache.set(resolve_cache_key || env['PATH_INFO'], content)
131
+ settings.cache.store(resolve_cache_key || env['PATH_INFO'], content)
121
132
  end
122
133
 
123
134
  logger.debug "SET Cache", began_at, @route.cache_key || env['PATH_INFO'] if defined?(logger)