Permalink
Browse files

clear_cache_store was being called regardless of the caching stragety…

…. Also added a get and set alias.
  • Loading branch information...
1 parent 743562d commit 065e4e6c14a98b7dba5b7814dcc0eac4eec882c5 @terrcin committed Nov 10, 2008
Showing with 6 additions and 1 deletion.
  1. +1 −1 lib/spandex_dispatcher_callback.rb
  2. +5 −0 lib/spandex_mem_cache_store.rb
View
2 lib/spandex_dispatcher_callback.rb
@@ -8,7 +8,7 @@ def self.included(base)
before_dispatch :clear_local_cache
def clear_local_cache
- Rails.cache.clear_local
+ Rails.cache.clear_local if Rails.cache.class == SpandexMemCacheStore
end
EOF
View
5 lib/spandex_mem_cache_store.rb
@@ -17,12 +17,16 @@ def read(key, options = nil)
end
value
end
+
+ alias :get :read
# Set key = value. Pass :unless_exist => true if you don't
# want to update the cache if the key is already set.
def write(key, value, options = nil)
@memcache_store.write(key, (@hash[key] = value || CACHED_NULL), options)
end
+
+ alias :set :write
def delete(key, options = nil)
@hash[key] = CACHED_NULL
@@ -51,6 +55,7 @@ def delete_matched(matcher, options = nil)
end
def clear_local
+ # calling @hash.clear is something like 20x slower than just using a new hash
@hash = Hash.new
end

0 comments on commit 065e4e6

Please sign in to comment.