MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / get

Method get

asyncpg/connection.py:2587–2608  ·  view source on GitHub ↗
(self, query, *, promote=True)

Source from the content-addressed store, hash-verified

2585 self._set_entry_timeout(entry)
2586
2587 def get(self, query, *, promote=True):
2588 if not self._max_size:
2589 # The cache is disabled.
2590 return
2591
2592 entry = self._entries.get(query) # type: _StatementCacheEntry
2593 if entry is None:
2594 return
2595
2596 if entry._statement.closed:
2597 # Happens in unittests when we call `stmt._state.mark_closed()`
2598 # manually or when a prepared statement closes itself on type
2599 # cache error.
2600 self._entries.pop(query)
2601 self._clear_entry_callback(entry)
2602 return
2603
2604 if promote:
2605 # `promote` is `False` when `get()` is called by `has()`.
2606 self._entries.move_to_end(query, last=True)
2607
2608 return entry._statement
2609
2610 def has(self, query):
2611 return self.get(query, promote=False) is not None

Callers 15

hasMethod · 0.95
git_commitishFunction · 0.80
initialize_optionsMethod · 0.80
finalize_optionsMethod · 0.80
setup.pyFile · 0.80
mainFunction · 0.80
test_standard_codecsMethod · 0.80
test_record_getMethod · 0.80

Calls 1

_clear_entry_callbackMethod · 0.95

Tested by 15

test_standard_codecsMethod · 0.64
test_record_getMethod · 0.64
test_listen_01Method · 0.64
test_listen_02Method · 0.64
test_log_listener_01Method · 0.64
test_log_listener_03Method · 0.64
retry_sleepMethod · 0.64