Sha256: 16ffb0f82fbadebd637504c1dabd6db9523c7f25832532c1157966681dfcd01d

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

class Zemanta
  class Fetcher
    class Cache
      extend ActiveSupport::Autoload

      autoload :NullResponse
      autoload :Response
      autoload :Key

      def initialize(opts = {})
        @key = Key.new(opts).to_s
      end

      def fetch
        fetch_from_storage(@key).to_s
      end

      def save(response)
        storage[@key] = Response.new(response) unless storage[@key]
      end

      private

      def storage
        Zemanta.config.cache_storage
      end

      def fetch_from_storage(opts)
        storage[@key] || NullResponse.new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zemanta_client-0.0.1 lib/zemanta/fetcher/cache.rb