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

Returns a new instance of RailsEntityStore.



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

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

Class Method Details

.resolve(uri) ⇒ Object



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

def self.resolve(uri)
  new
end

Instance Method Details

#exist?(key) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#open(key) ⇒ Object



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

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

#read(key) ⇒ Object



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

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

#write(body) ⇒ Object



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

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