Sha256: 7b973e9f56e0ba05cae0c0378732a52997027381f5bc20422d4c28ca74c2f61c

Contents?: true

Size: 1.07 KB

Versions: 210

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

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

210 entries across 198 versions & 12 rubygems

Version Path
actionpack-7.0.8.6 lib/action_dispatch/http/rack_cache.rb
actionpack-6.1.7.10 lib/action_dispatch/http/rack_cache.rb
actionpack-6.1.7.9 lib/action_dispatch/http/rack_cache.rb
actionpack-7.0.8.5 lib/action_dispatch/http/rack_cache.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actionpack-7.0.8.4/lib/action_dispatch/http/rack_cache.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/actionpack-7.0.5.1/lib/action_dispatch/http/rack_cache.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/actionpack-7.0.5.1/lib/action_dispatch/http/rack_cache.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/actionpack-7.0.5.1/lib/action_dispatch/http/rack_cache.rb
actionpack-7.0.8.4 lib/action_dispatch/http/rack_cache.rb
actionpack-6.1.7.8 lib/action_dispatch/http/rack_cache.rb
actionpack-7.0.8.1 lib/action_dispatch/http/rack_cache.rb
actionpack-6.1.7.7 lib/action_dispatch/http/rack_cache.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionpack-7.0.2.3/lib/action_dispatch/http/rack_cache.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionpack-7.0.3.1/lib/action_dispatch/http/rack_cache.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/http/rack_cache.rb
actionpack-7.0.8 lib/action_dispatch/http/rack_cache.rb
actionpack-7.0.7.2 lib/action_dispatch/http/rack_cache.rb
actionpack-6.1.7.6 lib/action_dispatch/http/rack_cache.rb
actionpack-7.0.7.1 lib/action_dispatch/http/rack_cache.rb
actionpack-6.1.7.5 lib/action_dispatch/http/rack_cache.rb