lib/active_support/cache.rb in activesupport-2.2.3 vs lib/active_support/cache.rb in activesupport-2.3.2
- old
+ new
@@ -1,10 +1,21 @@
require 'benchmark'
module ActiveSupport
# See ActiveSupport::Cache::Store for documentation.
module Cache
+ autoload :FileStore, 'active_support/cache/file_store'
+ autoload :MemoryStore, 'active_support/cache/memory_store'
+ autoload :SynchronizedMemoryStore, 'active_support/cache/synchronized_memory_store'
+ autoload :DRbStore, 'active_support/cache/drb_store'
+ autoload :MemCacheStore, 'active_support/cache/mem_cache_store'
+ autoload :CompressedMemCacheStore, 'active_support/cache/compressed_mem_cache_store'
+
+ module Strategy
+ autoload :LocalCache, 'active_support/cache/strategy/local_cache'
+ end
+
# Creates a new CacheStore object according to the given options.
#
# If no arguments are passed to this method, then a new
# ActiveSupport::Cache::MemoryStore object will be returned.
#
@@ -134,17 +145,17 @@
elsif block_given?
@logger_off = false
log("miss", key, options)
value = nil
- seconds = Benchmark.realtime { value = yield }
+ ms = Benchmark.ms { value = yield }
@logger_off = true
write(key, value, options)
@logger_off = false
- log("write (will save #{'%.2f' % (seconds * 1000)}ms)", key, nil)
+ log('write (will save %.2fms)' % ms, key, nil)
value
end
end
@@ -213,11 +224,5 @@
logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@silence && !@logger_off
end
end
end
end
-
-require 'active_support/cache/file_store'
-require 'active_support/cache/memory_store'
-require 'active_support/cache/drb_store'
-require 'active_support/cache/mem_cache_store'
-require 'active_support/cache/compressed_mem_cache_store'