Add configuration of the storage backend
Signed-off-by: kolaente <k@knt.li>
This commit is contained in:
parent
e9e3445397
commit
0ed3484457
|
@ -124,6 +124,8 @@ const (
|
|||
BackgroundsUnsplashEnabled Key = `backgrounds.providers.unsplash.enabled`
|
||||
BackgroundsUnsplashAccessToken Key = `backgrounds.providers.unsplash.accesstoken`
|
||||
BackgroundsUnsplashApplicationID Key = `backgrounds.providers.unsplash.applicationid`
|
||||
|
||||
KeyvalueType Key = `keyvalue.type`
|
||||
)
|
||||
|
||||
// GetString returns a string config value
|
||||
|
@ -277,6 +279,8 @@ func InitDefaultConfig() {
|
|||
BackgroundsEnabled.setDefault(true)
|
||||
BackgroundsUploadEnabled.setDefault(true)
|
||||
BackgroundsUnsplashEnabled.setDefault(false)
|
||||
// Key Value
|
||||
KeyvalueType.setDefault("memory")
|
||||
}
|
||||
|
||||
// InitConfig initializes the config, sets defaults etc.
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
package keyvalue
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/modules/keyvalue/memory"
|
||||
"code.vikunja.io/api/pkg/modules/keyvalue/redis"
|
||||
)
|
||||
|
||||
// Storage defines an interface for saving key-value pairs
|
||||
|
@ -32,7 +34,13 @@ var store Storage
|
|||
|
||||
// InitStorage initializes the configured storage backend
|
||||
func InitStorage() {
|
||||
store = memory.NewStorage()
|
||||
switch config.KeyvalueType.GetString() {
|
||||
case "redis":
|
||||
store = redis.NewStorage()
|
||||
case "memory":
|
||||
default:
|
||||
store = memory.NewStorage()
|
||||
}
|
||||
}
|
||||
|
||||
// Put puts a value in the storage backend
|
||||
|
|
Loading…
Reference in New Issue