Allow control over which storage cache to use
This allows one to better control the usage of the cache and turn it off completely. The storage configuration module was modified to allow parameters to be passed to just the storage implementation, rather than to the driver. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
6ab228f798
commit
4e1ecad6cc
1 changed files with 22 additions and 5 deletions
|
@ -103,11 +103,28 @@ func NewApp(ctx context.Context, configuration configuration.Configuration) *App
|
|||
app.configureEvents(&configuration)
|
||||
app.configureRedis(&configuration)
|
||||
|
||||
if app.redis != nil {
|
||||
// configure storage caches
|
||||
if cc, ok := configuration.Storage["cache"]; ok {
|
||||
switch cc["layerinfo"] {
|
||||
case "redis":
|
||||
if app.redis == nil {
|
||||
panic("redis configuration required to use for layerinfo cache")
|
||||
}
|
||||
app.registry = storage.NewRegistryWithDriver(app.driver, cache.NewRedisLayerInfoCache(app.redis))
|
||||
} else {
|
||||
// always fall back to inmemory storage
|
||||
ctxu.GetLogger(app).Infof("using redis layerinfo cache")
|
||||
case "inmemory":
|
||||
app.registry = storage.NewRegistryWithDriver(app.driver, cache.NewInMemoryLayerInfoCache())
|
||||
ctxu.GetLogger(app).Infof("using inmemory layerinfo cache")
|
||||
default:
|
||||
if cc["layerinfo"] != "" {
|
||||
ctxu.GetLogger(app).Warnf("unkown cache type %q, caching disabled", configuration.Storage["cache"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if app.registry == nil {
|
||||
// configure the registry if no cache section is available.
|
||||
app.registry = storage.NewRegistryWithDriver(app.driver, nil)
|
||||
}
|
||||
|
||||
app.registry, err = applyRegistryMiddleware(app.registry, configuration.Middleware["registry"])
|
||||
|
|
Loading…
Reference in a new issue