Class: DohDb::CacheConnector
- Inherits:
-
Object
- Object
- DohDb::CacheConnector
- Defined in:
- lib/dohmysql/cache_connector.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ CacheConnector
constructor
A new instance of CacheConnector.
- #request_handle(database = nil) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(config) ⇒ CacheConnector
Returns a new instance of CacheConnector.
9 10 11 12 13 |
# File 'lib/dohmysql/cache_connector.rb', line 9 def initialize(config) @config = config @config[:timeout] ||= 1800 @handle = nil end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/dohmysql/cache_connector.rb', line 7 def config @config end |
Instance Method Details
#request_handle(database = nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/dohmysql/cache_connector.rb', line 15 def request_handle(database = nil) if @handle close_handle('handle was unused for too long') if passed_timeout? @handle = nil if @handle && @handle.closed? end @last_used = Time.now @handle ||= get_new_handle(database) end |
#reset ⇒ Object
24 25 26 |
# File 'lib/dohmysql/cache_connector.rb', line 24 def reset close_handle('reset was called') end |