aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/cache.rb8
-rw-r--r--activesupport/lib/active_support/cache/file_store.rb7
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb8
-rw-r--r--activesupport/lib/active_support/cache/memory_store.rb7
4 files changed, 25 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index b3c9c23d9f..2f1143e610 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -87,8 +87,12 @@ module ActiveSupport
def delete_matched(matcher, options = nil)
log("delete matched", matcher.inspect, options)
- end
-
+ end
+
+ def exist?(key, options = nil)
+ log("exist?", key, options)
+ end
+
def increment(key, amount = 1)
log("incrementing", key, amount)
if num = read(key)
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb
index 16a2509ce2..5b771b1da0 100644
--- a/activesupport/lib/active_support/cache/file_store.rb
+++ b/activesupport/lib/active_support/cache/file_store.rb
@@ -40,13 +40,18 @@ module ActiveSupport
end
end
+ def exist?(name, options = nil)
+ super
+ File.exist?(real_file_path(name))
+ end
+
private
def real_file_path(name)
'%s/%s.cache' % [@cache_path, name.gsub('?', '.').gsub(':', '.')]
end
def ensure_cache_path(path)
- FileUtils.makedirs(path) unless File.exists?(path)
+ FileUtils.makedirs(path) unless File.exist?(path)
end
def search_dir(dir, &callback)
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index bfe7e2ccf3..b3769b812f 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -48,7 +48,13 @@ module ActiveSupport
rescue MemCache::MemCacheError => e
logger.error("MemCacheError (#{e}): #{e.message}")
false
- end
+ end
+
+ def exist?(key, options = nil)
+ # Doesn't call super, cause exist? in memcache is in fact a read
+ # But who cares? Reading is very fast anyway
+ !read(key, options).nil?
+ end
def increment(key, amount = 1)
log("incrementing", key, amount)
diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb
index 4872e025cd..6f114273e4 100644
--- a/activesupport/lib/active_support/cache/memory_store.rb
+++ b/activesupport/lib/active_support/cache/memory_store.rb
@@ -24,7 +24,12 @@ module ActiveSupport
super
@data.delete_if { |k,v| k =~ matcher }
end
-
+
+ def exist?(name,options = nil)
+ super
+ @data.has_key?(name)
+ end
+
def clear
@data.clear
end