Sha256: c131aecb718314732370d789cdc8f95e34ae9c84c2b2b5392453fdf3cf04e65e

Contents?: true

Size: 1.09 KB

Versions: 180

Compression:

Stored size: 1.09 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

    # TODO: Finally deal with the RAILS_CACHE global
    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

180 entries across 141 versions & 18 rubygems

Version Path
actionpack-3.2.22.5 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.22.4 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.22.3 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.22.2 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.22.1 lib/action_dispatch/http/rack_cache.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.22 lib/action_dispatch/http/rack_cache.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/actionpack-3.2.12/lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.21 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.20 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.19 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.18 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.17 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.16 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.15 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.15.rc3 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.15.rc2 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.15.rc1 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.14 lib/action_dispatch/http/rack_cache.rb
actionpack-3.2.14.rc2 lib/action_dispatch/http/rack_cache.rb