Sha256: 5ce8555625c61b7adf0be2f51f071320e5734b979930282d5fbc43e4b572581a
Contents?: true
Size: 718 Bytes
Versions: 2
Compression:
Stored size: 718 Bytes
Contents
# frozen_string_literal: true require "pathname" module HTTPX::Plugins module ResponseCache class FileStore < Store def initialize(dir = Dir.tmpdir) @dir = Pathname.new(dir) end def clear # delete all files end def cached?(request) file_path = @dir.join(request.response_cache_key) exist?(file_path) end private def _get(request) return unless cached?(request) File.open(@dir.join(request.response_cache_key)) end def _set(request, response) file_path = @dir.join(request.response_cache_key) response.copy_to(file_path) response.body.rewind end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
httpx-0.24.1 | lib/httpx/plugins/response_cache/file_store.rb |
httpx-0.24.0 | lib/httpx/plugins/response_cache/file_store.rb |