From 095bed99d981570f2016b4552219e5155773dab8 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 25 Oct 2006 19:37:00 +0000 Subject: Strings returned by get_cached now have a cached? method which returns true or false depending on whether the result was taken from the cache or not. --- lib/rbot/httputil.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/rbot') diff --git a/lib/rbot/httputil.rb b/lib/rbot/httputil.rb index 3f2da1a5..c1c8f4c1 100644 --- a/lib/rbot/httputil.rb +++ b/lib/rbot/httputil.rb @@ -354,12 +354,14 @@ class HttpUtil if expired?(uri, readtimeout, opentimeout) debug "Cache expired" bod = get(uri, readtimeout, opentimeout, max_redir, [noexpire]) + def bod.cached?; false; end else k = uri.to_s debug "Using cache" @cache[k][:count] += 1 @cache[k][:last_use] = Time.now bod = @cache[k][:body] + def bod.cached?; true; end end unless noexpire remove_stale_cache -- cgit v1.2.3