Change keyvalue.Get to return if a value exists or not instead of an error
This commit is contained in:
@ -91,7 +91,7 @@ func SetUserActive(a web.Auth) (err error) {
|
||||
|
||||
// getActiveUsers returns the active users from redis
|
||||
func getActiveUsers() (users activeUsersMap, err error) {
|
||||
u, err := keyvalue.Get(ActiveUsersKey)
|
||||
u, _, err := keyvalue.Get(ActiveUsersKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/modules/keyvalue"
|
||||
e "code.vikunja.io/api/pkg/modules/keyvalue/error"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
@ -97,13 +96,14 @@ func InitMetrics() {
|
||||
|
||||
// GetCount returns the current count from redis
|
||||
func GetCount(key string) (count int64, err error) {
|
||||
cnt, err := keyvalue.Get(key)
|
||||
cnt, exists, err := keyvalue.Get(key)
|
||||
if err != nil {
|
||||
if e.IsErrValueNotFoundForKey(err) {
|
||||
return 0, nil
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
if !exists {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
count = cnt.(int64)
|
||||
|
||||
return
|
||||
|
Reference in New Issue
Block a user