Class: DeploymentTask::LockAdapters::MysqlAdapter
- Defined in:
- lib/deployment_task/lock_adapters/mysql_adapter.rb
Constant Summary collapse
- LOCK_TIMEOUT =
Non-blocking
0
Instance Method Summary collapse
Methods inherited from Base
detect_database_adapter, resolve, #with_lock
Instance Method Details
#acquire(version) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/deployment_task/lock_adapters/mysql_adapter.rb', line 8 def acquire(version) result = connection.select_value( "SELECT GET_LOCK(#{connection.quote(lock_key(version))}, #{LOCK_TIMEOUT})" ) unless result == 1 raise LockNotAcquiredError, "Could not acquire lock for task #{version}. " \ "Another process may be executing it." end end |
#release(version) ⇒ Object
19 20 21 22 23 |
# File 'lib/deployment_task/lock_adapters/mysql_adapter.rb', line 19 def release(version) connection.select_value( "SELECT RELEASE_LOCK(#{connection.quote(lock_key(version))})" ) end |