Sha256: 78e714f0cc6b8f0e31c31b1055c724ef6dec8e4cec81461a953869a01b8a30e9

Contents?: true

Size: 1.04 KB

Versions: 181

Compression:

Stored size: 1.04 KB

Contents

require "rack/cache"
require "rack/cache/context"
require "active_support/cache"

module ActionDispatch
  class RailsMetaStore < Rack::Cache::MetaStore
    def self.resolve(uri)
      new
    end

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

    def read(key)
      if data = @store.read(key)
        Marshal.load(data)
      else
        []
      end
    end

    def write(key, value)
      @store.write(key, Marshal.dump(value))
    end

    ::Rack::Cache::MetaStore::RAILS = self
  end

  class RailsEntityStore < Rack::Cache::EntityStore
    def self.resolve(uri)
      new
    end

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

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

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

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

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

    ::Rack::Cache::EntityStore::RAILS = self
  end
end

Version data entries

181 entries across 176 versions & 12 rubygems

Version Path
actionpack-5.1.0.rc1 lib/action_dispatch/http/rack_cache.rb
actionpack-5.0.2 lib/action_dispatch/http/rack_cache.rb
actionpack-5.0.2.rc1 lib/action_dispatch/http/rack_cache.rb
actionpack-5.1.0.beta1 lib/action_dispatch/http/rack_cache.rb
actionpack-4.2.8 lib/action_dispatch/http/rack_cache.rb
actionpack-4.2.8.rc1 lib/action_dispatch/http/rack_cache.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/http/rack_cache.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/http/rack_cache.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/http/rack_cache.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/http/rack_cache.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/http/rack_cache.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/http/rack_cache.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/http/rack_cache.rb
abaci-0.3.0 vendor/bundle/gems/actionpack-5.0.0/lib/action_dispatch/http/rack_cache.rb
actionpack-5.0.1 lib/action_dispatch/http/rack_cache.rb
actionpack-5.0.1.rc2 lib/action_dispatch/http/rack_cache.rb
actionpack-5.0.1.rc1 lib/action_dispatch/http/rack_cache.rb
actionpack-5.0.0.1 lib/action_dispatch/http/rack_cache.rb
actionpack-4.2.7.1 lib/action_dispatch/http/rack_cache.rb
actionpack-4.2.7 lib/action_dispatch/http/rack_cache.rb