Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat: Implement caching layer for LazyOption #444
feat: Implement caching layer for LazyOption #444
Changes from 12 commits
5bdeeaa
319cab5
a6281f1
06f2543
db36b89
1a6199a
553fda7
ce3f320
73af9c6
c1d06b8
9bd2c28
a252c23
b428a98
3e1eced
eacfbd1
237c23e
bd91b78
3c49a7a
f8f975c
61999b7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Nothing to change here I don't think, but just want to note that in the case that the storage value already exists, this will not clear the key/value and this could lead to a corrupted state. Could potentially be a foot gun for a developer not aware of the internals of this.
Does
env::storage_remove
charge gas if there was no value at that KV previously, @evgenykuzyakov?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.
According to near-vm-logic/src/logic.rs, it does charge gas and it looks to be the same amount of gas if the value were present in storage.
But this begs the question about how we should handle already stored values when creating new
LazyOption
s. Right now, doingLazyOption::new(key, Some(val))
would effectively replace the value in storage, whileLazyOption::new(key, None)
doesn't do anything and allowsLazyOption::get
to retrieve the value from storage. This behavior is the same withcollections::LazyOption
.If we have
LazyOption::new(key, None)
be similar to replacing/deleting the value in storage, then we might need a new way to create aLazyOption
where it doesn't do anything and we can callLazyOption::get
.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.
yeah I think it's fine for now, and we can just think through any edge cases before we stabilize this!