-
Notifications
You must be signed in to change notification settings - Fork 9
On-disk cache #67
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
On-disk cache #67
Conversation
|
|
||
|
|
||
| def _create_table(c, conn, table_name): | ||
| c.execute( |
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.
we can simply use Connection ctx manager:
with conn:
conn.execute
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.
I think this isn't available on 3.9, but can double-check.
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.
Actually, it is available, but do we want to do that rather than just reuse the same cursor object repeatedly?
|
|
||
| def _insert_into_cache(c, conn, table_name, key, result, chain): | ||
| try: | ||
| c.execute( |
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.
connection context manager?
| chain = self.url | ||
| if not (local_chain := _check_if_local(chain)) or not USE_CACHE: | ||
| result = _retrieve_from_cache(c, table_name, key, chain) | ||
| if result is not None: |
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.
is it possible to cache None value?
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.
is it possible to cache
Nonevalue?
Yes. But none of the cached methods can ever return None.
…tead only use it in an experimental new class for just async substrate.
Caches commonly used functions on-disk