Sha256: 0450dca751f1805a353b83ac0cad76ddecba75e8f542533bff7805b3f98253e2
Contents?: true
Size: 966 Bytes
Versions: 3
Compression:
Stored size: 966 Bytes
Contents
# frozen_string_literal: true require "redfish_client/connector" module RedfishClient # Variant of {RedfishClient::Connector} that caches GET responses. class CachingConnector < Connector # Create new caching connector. # # @param url [String] base url of the Redfish service # @param verify [Boolean] verify SSL certificate of the service def initialize(url, verify = true) super @cache = {} end # Issue GET request to service. # # Request is only issued if there is no cache entry for the existing path. # # @param path [String] path to the resource, relative to the base url # @return [Excon::Response] response object def get(path) @cache[path] ||= super end # Clear the cached responses. # # Next GET request will repopulate the cache. def reset(path: nil) if path.nil? @cache = {} else @cache.delete(path) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
redfish_client-0.4.1 | lib/redfish_client/caching_connector.rb |
redfish_client-0.4.0 | lib/redfish_client/caching_connector.rb |
redfish_client-0.3.0 | lib/redfish_client/caching_connector.rb |