Sha256: 2b3e52dd424ec61de1121b21da20d9e5779c72b94dd27de1fad9830f8345b35e

Contents?: true

Size: 830 Bytes

Versions: 53

Compression:

Stored size: 830 Bytes

Contents

module AppManager
  module Actions
    class ResponseCache
      def initialize(cache_path)
        @cache_path = cache_path
        @expires_in = AppManager.configuration.expires_in || 1.day
      end

      def present?
        cached_response.present?
      end

      def body
        cached_response['body']
      end

      def status
        cached_response['status']
      end

      def headers
        cached_response['headers']
      end

      def cached_response
        @cached_response ||= Rails.cache.read(@cache_path)
      end

      def write_cache(response)
        cache_object = {
          body: response.body,
          status: response.status,
          headers: response.headers
        }.as_json
        Rails.cache.write(@cache_path, cache_object, expires_in: @expires_in)
      end

    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
app_manager-2.3.4 lib/app_manager/response_cache.rb
app_manager-2.3.3 lib/app_manager/response_cache.rb
app_manager-2.3.2 lib/app_manager/response_cache.rb
app_manager-2.3.1 lib/app_manager/response_cache.rb
app_manager-2.3.0 lib/app_manager/response_cache.rb
app_manager-2.2.4 lib/app_manager/response_cache.rb
app_manager-2.2.3 lib/app_manager/response_cache.rb
app_manager-2.2.2 lib/app_manager/response_cache.rb
app_manager-2.2.0 lib/app_manager/response_cache.rb
app_manager-2.0.0 lib/app_manager/response_cache.rb
app_manager-1.7.0 lib/app_manager/response_cache.rb
app_manager-1.6.3 lib/app_manager/response_cache.rb
app_manager-1.6.2 lib/app_manager/response_cache.rb
app_manager-1.6.1 lib/app_manager/response_cache.rb
app_manager-1.6.0 lib/app_manager/response_cache.rb
app_manager-1.5.1 lib/app_manager/response_cache.rb
app_manager-1.5.0 lib/app_manager/response_cache.rb
app_manager-1.4.4 lib/app_manager/response_cache.rb
app_manager-1.4.3 lib/app_manager/response_cache.rb
app_manager-1.4.2 lib/app_manager/response_cache.rb