Skip to content

Add new max_cached_statement_lifetime parameter to Connection. #109

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2017

Conversation

1st1
Copy link
Member

@1st1 1st1 commented Mar 31, 2017

The parameter allows asyncpg to refresh cached prepared statements
periodically.

See also issue #76.

@1st1 1st1 requested a review from elprans March 31, 2017 17:16
@@ -456,3 +461,21 @@ class TestPrepare(tb.ConnectedTestCase):
# Check that we can run queries after a failed cursor
# operation.
await check_simple()

async def test_prepare_24_max_use_count(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to test_prepare_max_lifetime

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return self._max_lifetime

def set_max_lifetime(self, new_lifetime):
self._max_lifetime = new_lifetime
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should cancel and reschedule all cleanup callbacks here. Also, what happens if new_lifetime is zero?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what happens if new_lifetime is zero?

Updated the documentation for max_cached_statement_lifetime: 0 means that statements can be cached indefinitely.

Pass ``0`` to disable the cache.

:param int max_cached_statement_lifetime:
number of seconds a prepared statement can stay in the cache.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the maximum time in seconds a prepared statement will stay in the cache

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@1st1
Copy link
Member Author

1st1 commented Apr 2, 2017

@elprans pushed another commit addressing your review

The parameter allows asyncpg to refresh cached prepared statements
periodically.

See also issue #76.
@1st1 1st1 merged commit 10955fd into master Apr 3, 2017
@1st1 1st1 deleted the use_count branch April 3, 2017 15:35
@1st1 1st1 changed the title Add new max_cached_statement_use_count parameter to Connection. Add new max_cached_statement_lifetime parameter to Connection. Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants