Skip to content
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

Interfacing stateDB cache #646

Merged
merged 2 commits into from Sep 1, 2020
Merged

Conversation

aidan-kwon
Copy link
Member

Proposed changes

  • This PR Interfaces stateDB cache
  • A new implementation of stateDB cache will be introduced

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

storage/statedb/cache.go Outdated Show resolved Hide resolved
@joowon-byun
Copy link
Contributor

I still see a fastcache.Stats in UpdateMetricNodes() and warmUpLoop(). Wouldn't this be interfaced, too?

@aidan-kwon
Copy link
Member Author

I still see a fastcache.Stats in UpdateMetricNodes() and warmUpLoop(). Wouldn't this be interfaced, too?

@winnie-byun I was intended at the first time to minimize change. Anyway, it is changed now.

@@ -0,0 +1,32 @@
package statedb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about changing this file to localcache.go?


import "github.com/VictoriaMetrics/fastcache"

type LocalCache struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name LocalCache suggests that there is a RemoteCache struct, but there isn't.
Also, LocalCache sounds like an interface, not a struct.
How about just wrapping fastcache.cache as statedb.FastCache?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. RemoteCache will be introduced later soon.
  2. When fastcache.cache is wrapped to statedb.FastCache, type assertion is needed in every method of statedb.FastCache to use methods of fastcache.cache. In that case, newly introduced interfaces should returns an error also.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am gonna try to find a new name replacing LocalCache later. If you have any idea, please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant for "wrapping fastcache.cache as statedb.FastCache" is to change the name of current LocalCache to FastCache, not changing the current interfaces. Let's proceed as what you intended and check if additional change is needed later. I think it is good for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I will consider your comment in the next PR.

@aidan-kwon aidan-kwon merged commit f99b4a2 into klaytn:dev Sep 1, 2020
@aidan-kwon aidan-kwon deleted the 0827-trieCache branch September 1, 2020 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants