Class: Vibe::Cache
- Inherits:
-
Object
- Object
- Vibe::Cache
- Extended by:
- Configuration
- Includes:
- Error
- Defined in:
- lib/vibe/cache.rb
Constant Summary collapse
- DRIVERS =
['FILE']
Constants included from Configuration
Vibe::Configuration::DEFAULT_API_KEY, Vibe::Configuration::DEFAULT_CACHE, Vibe::Configuration::DEFAULT_CACHE_DRIVER, Vibe::Configuration::DEFAULT_ENDPOINT, Vibe::Configuration::DEFAULT_FORMAT, Vibe::Configuration::DEFAULT_METHOD, Vibe::Configuration::DEFAULT_USER_AGENT, Vibe::Configuration::VALID_CONFIG_KEYS, Vibe::Configuration::VALID_CONNECTION_KEYS, Vibe::Configuration::VALID_OPTIONS_KEYS
Instance Method Summary collapse
-
#get(key = '') ⇒ Driver.get
Get key from cache, proxies into method with same name in driver class.
-
#initialize(options = {}) ⇒ Cache
constructor
A new instance of Cache.
-
#put(key = '', data = '') ⇒ Driver.put
Write to cache, proxies into method with same name in driver class.
Methods included from Configuration
configure, extended, options, reset
Constructor Details
#initialize(options = {}) ⇒ Cache
Returns a new instance of Cache.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/vibe/cache.rb', line 9 def initialize( = {}) # If invalid cache driver given if .include?(:driver) && !DRIVERS.include?([:driver]) raise ArgumentError, "unkown cache driver: #{[:driver]}" else # Load the required cache driver require "vibe/cache-drivers/#{[:driver].downcase}" @driver = eval([:driver].downcase.capitalize).new end end |
Instance Method Details
#get(key = '') ⇒ Driver.get
Get key from cache, proxies into method with same name in driver class
24 25 26 |
# File 'lib/vibe/cache.rb', line 24 def get(key = '') @driver.get(key) end |
#put(key = '', data = '') ⇒ Driver.put
Write to cache, proxies into method with same name in driver class
32 33 34 |
# File 'lib/vibe/cache.rb', line 32 def put(key = '', data = '') @driver.put(key, data) end |