Update module ulule/limiter/v3 to v3.8.0 (#699)
fmt Upgrade redis client to v8 everywhere Update module ulule/limiter/v3 to v3.8.0 Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/699 Co-Authored-By: renovate <renovatebot@kolaente.de> Co-Committed-By: renovate <renovatebot@kolaente.de>
This commit is contained in:
@ -18,13 +18,14 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/go-errors/errors"
|
||||
|
||||
e "code.vikunja.io/api/pkg/modules/keyvalue/error"
|
||||
"code.vikunja.io/api/pkg/red"
|
||||
"github.com/go-redis/redis/v7"
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
// Storage is a redis implementation of a keyvalue storage
|
||||
@ -48,12 +49,12 @@ func (s *Storage) Put(key string, value interface{}) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.client.Set(key, v, 0).Err()
|
||||
return s.client.Set(context.Background(), key, v, 0).Err()
|
||||
}
|
||||
|
||||
// Get retrieves a saved value from redis
|
||||
func (s *Storage) Get(key string) (value interface{}, err error) {
|
||||
b, err := s.client.Get(key).Bytes()
|
||||
b, err := s.client.Get(context.Background(), key).Bytes()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
return nil, &e.ErrValueNotFoundForKey{Key: key}
|
||||
@ -67,15 +68,15 @@ func (s *Storage) Get(key string) (value interface{}, err error) {
|
||||
|
||||
// Del removed a value from redis
|
||||
func (s *Storage) Del(key string) (err error) {
|
||||
return s.client.Del(key).Err()
|
||||
return s.client.Del(context.Background(), key).Err()
|
||||
}
|
||||
|
||||
// IncrBy increases the value saved at key by the amount provided through update
|
||||
func (s *Storage) IncrBy(key string, update int64) (err error) {
|
||||
return s.client.IncrBy(key, update).Err()
|
||||
return s.client.IncrBy(context.Background(), key, update).Err()
|
||||
}
|
||||
|
||||
// DecrBy decreases the value saved at key by the amount provided through update
|
||||
func (s *Storage) DecrBy(key string, update int64) (err error) {
|
||||
return s.client.DecrBy(key, update).Err()
|
||||
return s.client.DecrBy(context.Background(), key, update).Err()
|
||||
}
|
||||
|
@ -17,9 +17,11 @@
|
||||
package red
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"github.com/go-redis/redis/v7"
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
var r *redis.Client
|
||||
@ -44,7 +46,7 @@ func InitRedis() {
|
||||
DB: config.RedisDB.GetInt(),
|
||||
})
|
||||
|
||||
err := r.Ping().Err()
|
||||
err := r.Ping(context.Background()).Err()
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
Reference in New Issue
Block a user