Add support for caching multipart in writethrough mode (#13507)

This commit is contained in:
Poorna K
2021-11-01 11:11:58 -04:00
committed by GitHub
parent 6d53e3c2d7
commit 15dcacc1fc
7 changed files with 975 additions and 91 deletions

View File

@@ -39,7 +39,7 @@ type Config struct {
WatermarkLow int `json:"watermark_low"`
WatermarkHigh int `json:"watermark_high"`
Range bool `json:"range"`
CommitWriteback bool `json:"-"`
CacheCommitMode string `json:"commit_mode"`
}
// UnmarshalJSON - implements JSON unmarshal interface for unmarshalling
@@ -155,12 +155,11 @@ func parseCacheExcludes(excludes string) ([]string, error) {
return excludesSlice, nil
}
func parseCacheCommitMode(commitStr string) (bool, error) {
func parseCacheCommitMode(commitStr string) (string, error) {
switch strings.ToLower(commitStr) {
case "writeback":
return true, nil
case "writethrough":
return false, nil
case "writeback", "writethrough":
return strings.ToLower(commitStr), nil
default:
return "", config.ErrInvalidCacheCommitValue(nil).Msg("cache commit value must be `writeback` or `writethrough`")
}
return false, config.ErrInvalidCacheCommitValue(nil).Msg("cache commit value must be `writeback` or `writethrough`")
}

View File

@@ -219,11 +219,11 @@ func LookupConfig(kvs config.KVS) (Config, error) {
cfg.Range = rng
}
if commit := env.Get(EnvCacheCommit, kvs.Get(Commit)); commit != "" {
cfg.CommitWriteback, err = parseCacheCommitMode(commit)
cfg.CacheCommitMode, err = parseCacheCommitMode(commit)
if err != nil {
return cfg, err
}
if cfg.After > 0 && cfg.CommitWriteback {
if cfg.After > 0 && cfg.CacheCommitMode != "" {
err := errors.New("cache after cannot be used with commit writeback")
return cfg, config.ErrInvalidCacheSetting(err)
}