Check if the aws function response hits the cache or not. If the cache hits:
raises an AwsNoChange exception if do_raise == :raise.
returnes parsed response from the cache if it exists or true otherwise.
If the cache miss or the caching is off then returns false.
# File lib/awsbase/right_awsbase.rb, line 254 def cache_hits?(function, response, do_raise=:raise) result = false if caching? function = function.to_sym # get rid of requestId (this bad boy was added for API 2008-08-08+ and it is uniq for every response) response = response.sub(%{<requestId>.+?</requestId>}, '') response_md5 = MD5.md5(response).to_s # check for changes unless @cache[function] && @cache[function][:response_md5] == response_md5 # well, the response is new, reset cache data update_cache(function, {:response_md5 => response_md5, :timestamp => Time.now, :hits => 0, :parsed => nil}) else # aha, cache hits, update the data and throw an exception if needed @cache[function][:hits] += 1 if do_raise == :raise raise(AwsNoChange, "Cache hit: #{function} response has not changed since "+ "#{@cache[function][:timestamp].strftime('%Y-%m-%d %H:%M:%S')}, "+ "hits: #{@cache[function][:hits]}.") else result = @cache[function][:parsed] || true end end end result end
Returns true if the describe_xxx responses are being cached
# File lib/awsbase/right_awsbase.rb, line 245 def caching? @params.key?(:cache) ? @params[:cache] : @@caching end
Return true if this instance works in multi_thread mode and false otherwise.
# File lib/awsbase/right_awsbase.rb, line 293 def multi_thread @params[:multi_thread] end
# File lib/awsbase/right_awsbase.rb, line 235 def signed_service_params(aws_secret_access_key, service_hash, http_verb=nil, host=nil, service=nil ) case signature_version.to_s when '0' then AwsUtils::sign_request_v0(aws_secret_access_key, service_hash) when '1' then AwsUtils::sign_request_v1(aws_secret_access_key, service_hash) when '2' then AwsUtils::sign_request_v2(aws_secret_access_key, service_hash, http_verb, host, service) else raise AwsError.new("Unknown signature version (#{signature_version.to_s}) requested") end end
Generated with the Darkfish Rdoc Generator 2.