mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
add Database#using_connection to get a connection from the pool and return it when work is done.
This commit is contained in:
parent
22db7d1043
commit
f836bbfccb
1 changed files with 10 additions and 0 deletions
|
@ -45,6 +45,16 @@ module DB
|
|||
@in_pool = true
|
||||
end
|
||||
|
||||
# yields a connection from the pool
|
||||
# the connection is returned to the pool after
|
||||
# when the block ends
|
||||
def using_connection
|
||||
connection = get_from_pool
|
||||
yield connection
|
||||
ensure
|
||||
return_to_pool connection
|
||||
end
|
||||
|
||||
include QueryMethods
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue