MCPcopy
hub / github.com/MagicStack/asyncpg / get

Method get

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

Source from the content-addressed store, hash-verified

2530 self._set_entry_timeout(entry)
2531
2532 def get(self, query, *, promote=True):
2533 if not self._max_size:
2534 # The cache is disabled.
2535 return
2536
2537 entry = self._entries.get(query) # type: _StatementCacheEntry
2538 if entry is None:
2539 return
2540
2541 if entry._statement.closed:
2542 # Happens in unittests when we call `stmt._state.mark_closed()`
2543 # manually or when a prepared statement closes itself on type
2544 # cache error.
2545 self._entries.pop(query)
2546 self._clear_entry_callback(entry)
2547 return
2548
2549 if promote:
2550 # `promote` is `False` when `get()` is called by `has()`.
2551 self._entries.move_to_end(query, last=True)
2552
2553 return entry._statement
2554
2555 def has(self, query):
2556 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
test_listen_01Method · 0.80
test_listen_02Method · 0.80

Calls 1

_clear_entry_callbackMethod · 0.95

Tested by 12

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
run_testcaseMethod · 0.64
test_logging_contextMethod · 0.64