Class: DohDb::CacheConnector
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#row_builder ⇒ Object
Returns the value of attribute row_builder.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(host = nil, username = nil, password = nil, database = nil, row_builder = nil) ⇒ CacheConnector
constructor
A new instance of CacheConnector.
- #request_handle(database = nil) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(host = nil, username = nil, password = nil, database = nil, row_builder = nil) ⇒ CacheConnector
Returns a new instance of CacheConnector.
10 11 12 13 14 15 16 17 18 |
# File 'lib/doh/mysql/cache_connector.rb', line 10 def initialize(host = nil, username = nil, password = nil, database = nil, row_builder = nil) @host = host @username = username @password = password @database = database @timeout = 1800 @port = nil @row_builder = row_builder || TypedRowBuilder.new end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
8 9 10 |
# File 'lib/doh/mysql/cache_connector.rb', line 8 def database @database end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/doh/mysql/cache_connector.rb', line 8 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/doh/mysql/cache_connector.rb', line 8 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
8 9 10 |
# File 'lib/doh/mysql/cache_connector.rb', line 8 def port @port end |
#row_builder ⇒ Object
Returns the value of attribute row_builder.
8 9 10 |
# File 'lib/doh/mysql/cache_connector.rb', line 8 def row_builder @row_builder end |
#timeout ⇒ Object
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/doh/mysql/cache_connector.rb', line 8 def timeout @timeout end |
#username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/doh/mysql/cache_connector.rb', line 8 def username @username end |
Instance Method Details
#request_handle(database = nil) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/doh/mysql/cache_connector.rb', line 20 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
29 30 31 |
# File 'lib/doh/mysql/cache_connector.rb', line 29 def reset close_handle("reset") end |