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.



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

def initialize(store = RAILS_CACHE)
  @store = store
end

Class Method Details

.resolve(uri) ⇒ Object



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

def self.resolve(uri)
  new
end

Instance Method Details

#exist?(key) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#open(key) ⇒ Object



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

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

#read(key) ⇒ Object



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

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

#write(body) ⇒ Object



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

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