summaryrefslogtreecommitdiff
path: root/system/db/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'system/db/config.go')
-rw-r--r--system/db/config.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/system/db/config.go b/system/db/config.go
index f1d1215..ecddd54 100644
--- a/system/db/config.go
+++ b/system/db/config.go
@@ -169,3 +169,39 @@ func PutConfig(key string, value interface{}) error {
func ConfigCache(key string) interface{} {
return configCache.Get(key)
}
+
+// LoadCacheConfig loads the config into a cache to be accessed by ConfigCache()
+func LoadCacheConfig() error {
+ c, err := ConfigAll()
+ if err != nil {
+ return err
+ }
+
+ // convert json => map[string]interface{} => url.Values
+ var kv map[string]interface{}
+ err = json.Unmarshal(c, &kv)
+ if err != nil {
+ return err
+ }
+
+ data := make(url.Values)
+ for k, v := range kv {
+ switch v.(type) {
+ case []string:
+ s := v.([]string)
+ for i := range s {
+ if i == 0 {
+ data.Set(k, s[i])
+ }
+
+ data.Add(k, s[i])
+ }
+ default:
+ data.Set(k, fmt.Sprintf("%v", v))
+ }
+ }
+
+ configCache = data
+
+ return nil
+}