Class: Apollo::Cache::SqliteCache
- Defined in:
- lib/apollo_crawler/cache/sqlite_cache.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :db => "apollo-crawler.db", :collection => "fetched_docs" }
Instance Method Summary collapse
- #get(key) ⇒ Object
- #initilize(options = {}) ⇒ Object
-
#set(key, value) ⇒ Object
Set value associated with key Return cached value.
-
#try_get(key, *args) ⇒ Object
Get value associated with key from cache.
Methods inherited from BaseCache
Constructor Details
This class inherits a constructor from Apollo::Cache::BaseCache
Instance Method Details
#get(key) ⇒ Object
39 40 41 |
# File 'lib/apollo_crawler/cache/sqlite_cache.rb', line 39 def get(key) return nil end |
#initilize(options = {}) ⇒ Object
33 34 35 36 37 |
# File 'lib/apollo_crawler/cache/sqlite_cache.rb', line 33 def initilize( = {}) super() @options = DEFAULT_OPTIONS.merge() end |
#set(key, value) ⇒ Object
Set value associated with key Return cached value
57 58 59 |
# File 'lib/apollo_crawler/cache/sqlite_cache.rb', line 57 def set(key, value) return value end |
#try_get(key, *args) ⇒ Object
Get value associated with key from cache
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/apollo_crawler/cache/sqlite_cache.rb', line 44 def try_get(key, *args) res = get(key) # Not found, Create, cache and return if res.nil? && block_given? res = yield args end return res end |