Skip to content

Commit

Permalink
Merge pull request #33 from adrianouno/master
Browse files Browse the repository at this point in the history
Change options checking order to skip redis if cache is nil

Looks good, thanks.
  • Loading branch information
stewartmckee committed Jan 22, 2015
2 parents 6eb69b1 + 825c9d0 commit 186d262
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/cobweb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get(url, options = @options)
content = {:base_url => url}

# check if it has already been cached
if ((@options[:cache_type] == :crawl_based && redis.get(unique_id)) || (@options[:cache_type] == :full && full_redis.get(unique_id))) && @options[:cache]
if @options[:cache] && ((@options[:cache_type] == :crawl_based && redis.get(unique_id)) || (@options[:cache_type] == :full && full_redis.get(unique_id)))
if @options[:cache_type] == :crawl_based
puts "Cache hit in crawl for #{url}" unless @options[:quiet]
content = HashUtil.deep_symbolize_keys(Marshal.load(redis.get(unique_id)))
Expand Down Expand Up @@ -327,7 +327,7 @@ def head(url, options = @options)
content = {:base_url => url}

# check if it has already been cached
if redis.get("head-#{unique_id}") and @options[:cache]
if @options[:cache] && redis.get("head-#{unique_id}")
puts "Cache hit for #{url}" unless @options[:quiet]
content = HashUtil.deep_symbolize_keys(Marshal.load(redis.get("head-#{unique_id}")))
else
Expand Down

0 comments on commit 186d262

Please sign in to comment.