summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-25 19:37:00 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-25 19:37:00 +0000
commit095bed99d981570f2016b4552219e5155773dab8 (patch)
tree9c5a5b27a40006d1ad78828aa78e20eeac027f50
parent236a12abf3b2c78061cd7188b264cc842630ec2e (diff)
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.
-rw-r--r--ChangeLog8
-rw-r--r--lib/rbot/httputil.rb2
2 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c9e7120..203bd3c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-10-25 Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
+
+ * HttpUtil: 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; this can be exploited by plugins that parse the
+ result in some particular way, since they can now skip the parsing
+ stage if they cache the parse result.
+
2006-10-24 Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
* HttpUtil: initial implementation of proper caching based on
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