diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 40298108..f34b98e9 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -11,9 +11,6 @@ require "active_support/json" # Simple callback library require "middleman-core/vendor/hooks-0.2.0/lib/hooks" -# Using a cache -require "middleman-core/cache" - require "middleman-core/sitemap" # Core Middleman Class @@ -309,9 +306,9 @@ module Middleman # Shared cache instance # # @private - # @return [Middleman::Cache] The cache + # @return [Middleman::Util::Cache] The cache def self.cache - @_cache ||= ::Middleman::Cache.new + @_cache ||= ::Middleman::Util::Cache.new end delegate :cache, :to => :"self.class" diff --git a/middleman-core/lib/middleman-core/cache.rb b/middleman-core/lib/middleman-core/cache.rb deleted file mode 100644 index 78ef5441..00000000 --- a/middleman-core/lib/middleman-core/cache.rb +++ /dev/null @@ -1,57 +0,0 @@ -module Middleman - # Simple shared cache implementation - class Cache - - # Initialize - def initialize - self.clear - end - - # Either get the cached key or save the contents of the block - # - # @param Anything Hash can use as a key - # @return Cached value - def fetch(*key) - @cache[key] ||= yield - end - - # Whether the key is in the cache - # - # @param Anything Hash can use as a key - # @return [Boolean] - def has_key?(key) - @cache.has_key?(key) - end - - # Get a specific key - # - # @param Anything Hash can use as a key - # @return Cached value - def get(key) - @cache[key] - end - - def keys - @cache.keys - end - - # Clear the entire cache - def clear - @cache = {} - end - - # Set a specific key - # - # @param Anything Hash can use as a key - # @param Cached value - def set(key, value) - @cache[key] = value - end - - # Remove a specific key - # @param Anything Hash can use as a key - def remove(*key) - @cache.delete(key) - end - end -end \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 747b8b40..520c1be4 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -31,5 +31,60 @@ module Middleman def self.normalize_path(path) path.sub(/^\//, "").gsub("%20", " ") end + + # Simple shared cache implementation + class Cache + # Initialize + def initialize + self.clear + end + + # Either get the cached key or save the contents of the block + # + # @param Anything Hash can use as a key + # @return Cached value + def fetch(*key) + @cache[key] ||= yield + end + + # Whether the key is in the cache + # + # @param Anything Hash can use as a key + # @return [Boolean] + def has_key?(key) + @cache.has_key?(key) + end + + # Get a specific key + # + # @param Anything Hash can use as a key + # @return Cached value + def get(key) + @cache[key] + end + + def keys + @cache.keys + end + + # Clear the entire cache + def clear + @cache = {} + end + + # Set a specific key + # + # @param Anything Hash can use as a key + # @param Cached value + def set(key, value) + @cache[key] = value + end + + # Remove a specific key + # @param Anything Hash can use as a key + def remove(*key) + @cache.delete(key) + end + end end end \ No newline at end of file