New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cached connection for Parameter lookup #385

Merged
merged 3 commits into from Feb 23, 2018

Conversation

Projects
None yet
2 participants
@bensyverson
Copy link
Contributor

bensyverson commented Feb 21, 2018

When looking up a model from a Parameter, request a cached connection to the DB rather than creating a fresh one. 馃幐

if let subcontainer = container as? SubContainer {
aConn = subcontainer.requestCachedConnection(to: dbid)
} else {
aConn = container.requestPooledConnection(to: dbid)

This comment has been minimized.

@tanner0101

tanner0101 Feb 21, 2018

Member

Need to either use .withPooledConnection or call .releasePooledConnection once the find has finished.

You can make use of a nested function here to prevent code-dupe.

(requestCachedConnection is fine not calling any release because it's assumed that a subcontainer will call release when it deallocates)

This comment has been minimized.

@bensyverson

bensyverson Feb 22, 2018

Author Contributor

Cool, that makes sense. Take a look at my changes and let me know if that's what you're thinking about for the nested function 馃憤

@tanner0101 tanner0101 added this to the 3.0.0-rc.1 milestone Feb 23, 2018

@tanner0101 tanner0101 self-assigned this Feb 23, 2018

@tanner0101

This comment has been minimized.

Copy link
Member

tanner0101 commented Feb 23, 2018

Thanks!

@tanner0101 tanner0101 merged commit 7f09520 into vapor:beta Feb 23, 2018

1 check passed

ci/circleci: linux Your tests passed on CircleCI!
Details

@bensyverson bensyverson deleted the bensyverson:beta branch Feb 23, 2018

@VaporNationTravis VaporNationTravis referenced this pull request Feb 23, 2018

Merged

Week 4 (WIP) #20

@Joannis Joannis added this to Done in Vapor 3 Feb 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment