From 2010e8ae19d0dec46d3eba1b1a5ada5bf80c789d Mon Sep 17 00:00:00 2001 From: coezbek Date: Mon, 7 Mar 2016 12:08:18 +0100 Subject: [PATCH] Return key as expired, if not in cache --- lib/diskcached.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/diskcached.rb b/lib/diskcached.rb index 263fb52..20a6d6b 100644 --- a/lib/diskcached.rb +++ b/lib/diskcached.rb @@ -45,11 +45,10 @@ def timeout=(t) @gc_time = t end - # return true if cache with 'key' is expired + # return true if cache with 'key' is expired or there is no cache entry def expired? key - return false if timeout.nil? mtime = read_cache_mtime(key) - return (mtime.nil? || mtime+timeout <= Time.now) + return mtime.nil? || (timeout && mtime+timeout <= Time.now) end # expire cache with 'key'