diff --git a/lib/readthis/cache.rb b/lib/readthis/cache.rb index 27bd6da..3407fc6 100644 --- a/lib/readthis/cache.rb +++ b/lib/readthis/cache.rb @@ -214,13 +214,31 @@ def fetch_multi(*keys) end end + # Returns `true` if the cache contains an entry for the given key. + # + # @param [String] Key for lookup + # @param [Hash] Optional overrides + # + # @example + # + # cache.exist?('some-key') # => false + # cache.exist?('some-key', namespace: 'cache') # => true + # def exist?(key, options = {}) invoke(:exist?, key) do |store| store.exists(namespaced_key(key, merged_options(options))) end end - def clear + # Clear the entire cache. This flushes the current database, no + # globbing is applied. + # + # @param [Hash] Options, only present for compatibility. + # + # @example + # + # cache.clear #=> 'OK' + def clear(options = {}) invoke(:clear, '*', &:flushdb) end