Skip to content

Commit

Permalink
Documentation and clear compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sorentwo committed Dec 30, 2014
1 parent 8f575a3 commit e655f75
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/readthis/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e655f75

Please sign in to comment.