Class: Apollo::Cache::MemcachedCache
- Defined in:
- lib/apollo_crawler/cache/memcached_cache.rb
Instance Method Summary collapse
-
#clear ⇒ Object
Clear cache.
-
#contains(key) ⇒ Object
Check if cache contains specified key.
-
#get(key, *args) ⇒ Object
Get value associated with key from cache.
-
#initialize ⇒ MemcachedCache
constructor
A new instance of MemcachedCache.
-
#invalidate(key) ⇒ Object
Invalidate key/value pair.
-
#set(key, value) ⇒ Object
Set value associated with key Return cached value.
Constructor Details
#initialize ⇒ MemcachedCache
Returns a new instance of MemcachedCache.
29 30 31 |
# File 'lib/apollo_crawler/cache/memcached_cache.rb', line 29 def initialize @cache = Dalli::Client.new() end |
Instance Method Details
#clear ⇒ Object
Clear cache
65 66 67 |
# File 'lib/apollo_crawler/cache/memcached_cache.rb', line 65 def clear # TODO: Implement end |
#contains(key) ⇒ Object
Check if cache contains specified key
55 56 57 |
# File 'lib/apollo_crawler/cache/memcached_cache.rb', line 55 def contains(key) # TODO: Implement end |
#get(key, *args) ⇒ Object
Get value associated with key from cache
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/apollo_crawler/cache/memcached_cache.rb', line 34 def get(key, *args) res = @cache.get(key) # Not found, Create, cache and return if res.nil? && block_given? res = yield args self.set(key, res) end return res end |
#invalidate(key) ⇒ Object
Invalidate key/value pair
60 61 62 |
# File 'lib/apollo_crawler/cache/memcached_cache.rb', line 60 def invalidate(key) # TODO: Implement end |
#set(key, value) ⇒ Object
Set value associated with key Return cached value
49 50 51 52 |
# File 'lib/apollo_crawler/cache/memcached_cache.rb', line 49 def set(key, value) @cache.set(key, value) return key end |