-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(config): add --cache-backend * feat(operation): embed cache.Cache into operation.Cache * feat(cache): support redis:// * test(integration): add redis test * chore(README): add --cache-backend * chore(mod): update * chore: add disclaimer
- Loading branch information
Showing
13 changed files
with
296 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package config | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/urfave/cli/v2" | ||
"golang.org/x/xerrors" | ||
) | ||
|
||
// CacheConfig holds the config for cache | ||
type CacheConfig struct { | ||
CacheBackend string | ||
} | ||
|
||
// NewCacheConfig returns an instance of CacheConfig | ||
func NewCacheConfig(c *cli.Context) CacheConfig { | ||
return CacheConfig{ | ||
CacheBackend: c.String("cache-backend"), | ||
} | ||
} | ||
|
||
// Init initialize the CacheConfig | ||
func (c *CacheConfig) Init() error { | ||
// "redis://" or "fs" are allowed for now | ||
// An empty value is also allowed for testability | ||
if !strings.HasPrefix(c.CacheBackend, "redis://") && | ||
c.CacheBackend != "fs" && c.CacheBackend != "" { | ||
return xerrors.Errorf("unsupported cache backend: %s", c.CacheBackend) | ||
} | ||
return nil | ||
} |
Oops, something went wrong.