Class: ActionDispatch::RailsEntityStore

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store = Rails.cache) ⇒ RailsEntityStore


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

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

Class Method Details

.resolve(uri) ⇒ Object


33
34
35
# File 'actionpack/lib/action_dispatch/http/rack_cache.rb', line 33

def self.resolve(uri)
  new
end

Instance Method Details

#exist?(key) ⇒ Boolean


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

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

#open(key) ⇒ Object


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

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

#read(key) ⇒ Object


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

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

#write(body) ⇒ Object


54
55
56
57
58
59
# File 'actionpack/lib/action_dispatch/http/rack_cache.rb', line 54

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