Cache db set and default fix.

This commit is contained in:
Ignacio Gómez 2018-02-14 10:48:20 -03:00
parent acd4b0ee68
commit a99b62299e
2 changed files with 7 additions and 5 deletions

View File

@ -138,13 +138,13 @@ auth_opt_cache_reset true
If `cache_reset` is set to false or omitted, cache won't be flushed upon service start.
Redis will use some defaults if no values are given. The following are possible configuration values for the cache:
Redis will use the following defaults if no values are given. Also, these are the available options for cache:
```
auth_opt_cache_host localhost
auth_opt_cache_port 6379
auth_opt_cache_password pwd
auth_opt_cache_db 0
auth_opt_cache_db 3
auth_opt_auth_cache_seconds 30
auth_opt_acl_cache_seconds 30
```

View File

@ -78,7 +78,7 @@ func AuthPluginInit(keys []string, values []string, authOptsNum int) {
Host: "localhost",
Port: "6379",
Password: "",
DB: 0,
DB: 3,
}
superusers := make([]string, 10, 10)
@ -331,8 +331,10 @@ func AuthPluginInit(keys []string, values []string, authOptsNum int) {
if cacheDB, ok := authOpts["cache_db"]; ok {
db, err := strconv.ParseInt(cacheDB, 10, 32)
if err != nil {
if err == nil {
cache.DB = int32(db)
} else {
log.Warningf("couldn't parse cache db (err: %s), defaulting to %d\n", err, cache.DB)
}
}
@ -367,7 +369,7 @@ func AuthPluginInit(keys []string, values []string, authOptsNum int) {
commonData.UseCache = false
} else {
commonData.RedisCache = goredisClient
log.Infof("started cache redis client")
log.Infof("started cache redis client on DB %d\n", cache.DB)
//Check if cache must be reset
if cacheReset, ok := authOpts["cache_reset"]; ok && cacheReset == "true" {
commonData.RedisCache.FlushDB()