mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-09-03 04:28:52 +02:00
🍱 fix logic
This commit is contained in:
Vendored
+2
-9
@@ -65,14 +65,14 @@ func (rc *redisCache) nextReader() *simpleredis.SimpleRedis {
|
|||||||
return &rc.readers[idx]
|
return &rc.readers[idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
func redisResultToString(value []byte, err error) (string, error) {
|
func (rc *redisCache) get(key string) (string, error) {
|
||||||
|
value, err := rc.nextReader().Get(key)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
valueString := string(value)
|
valueString := string(value)
|
||||||
if len(valueString) > 0 {
|
if len(valueString) > 0 {
|
||||||
return valueString, nil
|
return valueString, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
switch err.Error() {
|
switch err.Error() {
|
||||||
case simpleredis.RedisMiss:
|
case simpleredis.RedisMiss:
|
||||||
return "", errors.New(CacheMiss)
|
return "", errors.New(CacheMiss)
|
||||||
@@ -81,13 +81,6 @@ func redisResultToString(value []byte, err error) (string, error) {
|
|||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return "", errors.New(CacheMiss)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rc *redisCache) get(key string) (string, error) {
|
|
||||||
value, err := rc.nextReader().Get(key)
|
|
||||||
return redisResultToString(value, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rc *redisCache) set(key, value string, duration int64) {
|
func (rc *redisCache) set(key, value string, duration int64) {
|
||||||
if err := rc.writer.Set(key, []byte(value), duration); err != nil {
|
if err := rc.writer.Set(key, []byte(value), duration); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user