Sha256: f018aaeca3e05b5d620cf30ab683ed9c18bff67530e69bf872941839faa87bbd

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

# :enddoc:

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

18 entries across 18 versions & 4 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/actionpack-7.1.3.4/lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.5.1 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.5 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.4.2 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.4.1 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.4 lib/action_dispatch/http/rack_cache.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actionpack-7.1.3.4/lib/action_dispatch/http/rack_cache.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/actionpack-7.1.3.4/lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.3.4 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.3.2 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.3.1 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.3 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.2 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.1 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.0 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.0.rc2 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.0.rc1 lib/action_dispatch/http/rack_cache.rb
actionpack-7.1.0.beta1 lib/action_dispatch/http/rack_cache.rb