Checks whether the connection to the database is still active. This includes checking whether the kv-store is actually capable of responding, i.e. whether the connection isn’t stale.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 68 def active? @active end
Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 59 def adapter_name 'Abstract' end
Begins the transaction (and turns off auto-committing).
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 122 def begin_db_transaction() end
Clear any caching the kv-store adapter may be doing. This is kv-store specific.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 97 def clear_cache! # this should be overridden by concrete adapters end
Check the connection back in to the connection pool
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 135 def close pool.checkin self end
Commits the transaction (and turns on auto-committing).
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 126 def commit_db_transaction() end
Disconnects from the kv-store if already connected. Otherwise, this method does nothing.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 80 def disconnect! @active = false end
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 53 def expire @in_use = false end
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 44 def lease synchronize do unless in_use @in_use = true @last_use = Time.now end end end
Provides access to the underlying kv-store driver for this adapter. For example, this method returns a Redis object in case of RedisAdapter.
This is useful for when you need to call a proprietary method.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 117 def raw_connection @connection end
Disconnects from the database if already connected, and establishes a new connection with the database.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 74 def reconnect! @active = true end
Returns true if its required to reload the connection between requests for development mode.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 102 def requires_reloading? false end
Reset the state of this connection, directing the kv-store to clear transactions and other connection-related server-side state. Usually a implementation-dependent operation.
The default implementation does nothing; the implementation should be overridden by concrete adapters.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 90 def reset! # this should be overridden by concrete adapters end
Rolls back the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 131 def rollback_db_transaction() end
Checks whether the connection to the kv-store is still active (i.e. not
stale). This is done under the hood by calling active?. If the
connection is no longer active, then this method will reconnect to the
kv-store.
# File lib/keymap/connection_adapters/abstract_adapter.rb, line 109 def verify! reconnect! unless active? end