mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-09-04 21:18:52 +02:00
The pooled simpleredis sends RESP arrays instead of inline commands, so the e2e redis stand-in answered +OK to the "*2" header and the plugin read "OK" as a cached verdict, blocking a request that should pass. The mock now parses RESP arrays, still accepts inline, and handles MGET. Points at pool-redis-connections until maxlerebourg/simpleredis#8 is tagged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
37 lines
1.0 KiB
Markdown
37 lines
1.0 KiB
Markdown
# simpleredis
|
|
Minimal go redis with only `get`, `mget`, `set` and `delete` operation.
|
|
It supports password authentication with redis.
|
|
With **NO** external dependencies.
|
|
|
|
Connections are pooled: a command reuses an already authenticated connection when
|
|
one is idle, so `AUTH` and `SELECT` are paid once per connection instead of once
|
|
per command. A `SimpleRedis` is safe for concurrent use and must not be copied
|
|
once initialized.
|
|
|
|
## Example
|
|
```go
|
|
import simpleredis "github.com/maxlerebourg/simpleredis"
|
|
|
|
var redis simpleredis.SimpleRedis
|
|
|
|
redis.Init("redis:6379", "", "") // redisHost, redisPass, redisDatabase
|
|
|
|
err := redis.Set("test", []byte("whatever"), 60) // Set key "test" with "whatever" for 60 seconds
|
|
if err != nil {
|
|
...
|
|
}
|
|
val, err := redis.Get("test") // get key test
|
|
if err != nil {
|
|
// err could be only redis:unreachable, redis:miss or redis:timeout available in simpleredis.RedisUnreachable
|
|
...
|
|
}
|
|
err = redis.Del("test")
|
|
if err != nil {
|
|
...
|
|
}
|
|
```
|
|
|
|
## Author
|
|
Max Lerebourg @ [Primadviz.com](https://primadviz.com)
|
|
Mathieu Hanotaux
|