mirror of
https://github.com/minio/minio.git
synced 2025-11-07 04:42:56 -05:00
Add support for caching multipart in writethrough mode (#13507)
This commit is contained in:
13
internal/config/cache/config.go
vendored
13
internal/config/cache/config.go
vendored
@@ -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`")
|
||||
}
|
||||
|
||||
4
internal/config/cache/lookup.go
vendored
4
internal/config/cache/lookup.go
vendored
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user