Class: ActionDispatch::RailsEntityStore

Inherits:
Rack::Cache::EntityStore
  • Object
show all
Defined in:
lib/action_dispatch/http/rack_cache.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store = Rails.cache) ⇒ RailsEntityStore

Returns a new instance of RailsEntityStore.



41
42
43
# File 'lib/action_dispatch/http/rack_cache.rb', line 41

def initialize(store = Rails.cache)
  @store = store
end

Class Method Details

.resolve(uri) ⇒ Object



37
38
39
# File 'lib/action_dispatch/http/rack_cache.rb', line 37

def self.resolve(uri)
  new
end

Instance Method Details

#exist?(key) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/action_dispatch/http/rack_cache.rb', line 45

def exist?(key)
  @store.exist?(key)
end

#open(key) ⇒ Object



49
50
51
# File 'lib/action_dispatch/http/rack_cache.rb', line 49

def open(key)
  @store.read(key)
end

#read(key) ⇒ Object



53
54
55
56
# File 'lib/action_dispatch/http/rack_cache.rb', line 53

def read(key)
  body = open(key)
  body.join if body
end

#write(body) ⇒ Object



58
59
60
61
62
63
# File 'lib/action_dispatch/http/rack_cache.rb', line 58

def write(body)
  buf = []
  key, size = slurp(body) { |part| buf << part }
  @store.write(key, buf)
  [key, size]
end