file.go: Added SaveToFileConcurrentWithTimeout#39
Open
ehnuje wants to merge 1 commit intoVictoriaMetrics:masterfrom
Open
file.go: Added SaveToFileConcurrentWithTimeout#39ehnuje wants to merge 1 commit intoVictoriaMetrics:masterfrom
ehnuje wants to merge 1 commit intoVictoriaMetrics:masterfrom
Conversation
cristaloleg
reviewed
Sep 21, 2020
| // The saved data may be loaded with LoadFromFile*. | ||
| // | ||
| // See also SaveToFileConcurrent. | ||
| func (c *Cache) SaveToFileConcurrentWithTimeout(filePath string, concurrency int, timeout time.Duration) error { |
There was a problem hiding this comment.
I suppose that passing io.Writer instead of filepath (and opening file inside) will be much more flexible and easier to test. WDYT?
Author
There was a problem hiding this comment.
@cristaloleg Thanks for the comment but I'm sorry that I don't quite understand your point "passing io.Writer and opening the file inside" 😭 Could you please elaborate? In this change, I wanted to make the function signature look like existing SaveToFileConcurrent.
There was a problem hiding this comment.
I was thinking about slightly another API:
func (c *Cache) SaveConcurrentWithTimeout(w io.Writer, concurrency int, timeout time.Duration) error {
Anyway, I'm the author of fastcache, someone else might have another view on this.
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SaveToFileConcurrent, if the cached data is too huge, it can take quite a lot of time.SaveToFileConcurrentand store as much as possible for the given time.SaveToFileConcurrentWithTimeoutis added to support that feature.