-
Notifications
You must be signed in to change notification settings - Fork 419
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
Conversation
tests/test_prepare.py
Outdated
@@ -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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
asyncpg/connection.py
Outdated
return self._max_lifetime | ||
|
||
def set_max_lifetime(self, new_lifetime): | ||
self._max_lifetime = new_lifetime |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
asyncpg/connection.py
Outdated
Pass ``0`` to disable the cache. | ||
|
||
:param int max_cached_statement_lifetime: | ||
number of seconds a prepared statement can stay in the cache. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@elprans pushed another commit addressing your review |
The parameter allows asyncpg to refresh cached prepared statements periodically. See also issue #76.
max_cached_statement_use_count
parameter to Connection.max_cached_statement_lifetime
parameter to Connection.
The parameter allows asyncpg to refresh cached prepared statements
periodically.
See also issue #76.