Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Moneta as entity and metastore #78

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/rack/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module Rack::Cache
autoload :Request, 'rack/cache/request'
autoload :Response, 'rack/cache/response'
autoload :Context, 'rack/cache/context'
autoload :Storage, 'rack/cache/storage'
autoload :CacheControl, 'rack/cache/cachecontrol'

# Create a new Rack::Cache middleware component that fetches resources from
Expand Down
52 changes: 0 additions & 52 deletions lib/rack/cache/appengine.rb

This file was deleted.

25 changes: 7 additions & 18 deletions lib/rack/cache/context.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rack/cache/options'
require 'rack/cache/request'
require 'rack/cache/response'
require 'rack/cache/storage'
require 'rack/cache/store'

module Rack::Cache
# Implements Rack's middleware interface and provides the context for all
Expand All @@ -23,24 +23,13 @@ def initialize(backend, options={})
initialize_options options
yield self if block_given?

@store = Store.new(self.options['rack-cache.metastore'],
self.options['rack-cache.entitystore'])

@private_header_keys =
private_headers.map { |name| "HTTP_#{name.upcase.tr('-', '_')}" }
end

# The configured MetaStore instance. Changing the rack-cache.metastore
# value effects the result of this method immediately.
def metastore
uri = options['rack-cache.metastore']
storage.resolve_metastore_uri(uri)
end

# The configured EntityStore instance. Changing the rack-cache.entitystore
# value effects the result of this method immediately.
def entitystore
uri = options['rack-cache.entitystore']
storage.resolve_entitystore_uri(uri)
end

# The Rack call interface. The receiver acts as a prototype and runs
# each request in a dup object unless the +rack.run_once+ variable is
# set in the environment.
Expand Down Expand Up @@ -146,7 +135,7 @@ def pass
# Invalidate POST, PUT, DELETE and all methods not understood by this cache
# See RFC2616 13.10
def invalidate
metastore.invalidate(@request, entitystore)
@store.invalidate(@request)
rescue Exception => e
log_error(e)
pass
Expand All @@ -166,7 +155,7 @@ def lookup
fetch
else
begin
entry = metastore.lookup(@request, entitystore)
entry = @store.lookup(@request)
rescue Exception => e
log_error(e)
return pass
Expand Down Expand Up @@ -264,7 +253,7 @@ def fetch
# Write the response to the cache.
def store(response)
strip_ignore_headers(response)
metastore.store(@request, response, entitystore)
@store.store(@request, response)
response.headers['Age'] = response.age.to_s
rescue Exception => e
log_error(e)
Expand Down
Loading