Update Redis adapter and storage to v1.2.0
This commit updates the Redis adapter and storage to version 1.2.0, changing the module name from "env-redis" to "env_redis". It also adds error logging for Redis load operations in the storage package. The README.md file has been updated with a new example configuration for using the updated module name in the storage block.main
parent
895360ba52
commit
9aa8a46a45
|
@ -4,8 +4,8 @@ RUN xcaddy build master \
|
|||
--with github.com/caddy-dns/digitalocean \
|
||||
--with github.com/caddy-dns/porkbun \
|
||||
--with github.com/mholt/caddy-dynamicdns \
|
||||
--with github.com/techio-dev/caddy-redis/adapt@v1.1.1 \
|
||||
--with github.com/techio-dev/caddy-redis/storage@v1.1.1
|
||||
--with github.com/techio-dev/caddy-redis/adapt@v1.2.0 \
|
||||
--with github.com/techio-dev/caddy-redis/storage@v1.2.0
|
||||
|
||||
FROM caddy:alpine
|
||||
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
10
README.md
10
README.md
|
@ -1,7 +1,13 @@
|
|||
# caddy-redis
|
||||
|
||||
command: ["caddy", "run", "--adapter=env-redis", "--config=/dev/null"]
|
||||
command: ["caddy", "run", "--adapter=env_redis", "--config=/dev/null"]
|
||||
|
||||
env:
|
||||
- REDIS_URL=redis://:password@host:port/db
|
||||
- NAME=caddy-redis
|
||||
- NAME=caddy-redis
|
||||
|
||||
{
|
||||
"storage": {
|
||||
"module": "env_redis"
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
caddyconfig.RegisterAdapter("env-redis", RedisAdapt{
|
||||
caddyconfig.RegisterAdapter("env_redis", RedisAdapt{
|
||||
ClientName: "lttech",
|
||||
})
|
||||
}
|
||||
|
|
|
@ -78,7 +78,12 @@ func (rs *RedisStorage) Store(_ context.Context, key string, value []byte) error
|
|||
}
|
||||
|
||||
func (rs *RedisStorage) Load(_ context.Context, key string) ([]byte, error) {
|
||||
return rs.RedisClient.Get(rs.prefixKey(key)).Bytes()
|
||||
val, err := rs.RedisClient.Get(rs.prefixKey(key)).Result()
|
||||
if err != nil {
|
||||
caddy.Log().Named("redis:Load").Error(fmt.Sprintf("err %v", err))
|
||||
return nil, err
|
||||
}
|
||||
return []byte(val), nil
|
||||
}
|
||||
|
||||
func (rs *RedisStorage) Delete(_ context.Context, key string) error {
|
||||
|
|
Loading…
Reference in New Issue