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.



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

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

Class Method Details

.resolve(uri) ⇒ Object



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

def self.resolve(uri)
  new
end

Instance Method Details

#exist?(key) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#open(key) ⇒ Object



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

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

#read(key) ⇒ Object



51
52
53
54
# File 'lib/action_dispatch/http/rack_cache.rb', line 51

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

#write(body) ⇒ Object



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

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