
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
github.com/pm-redemption/redis
abulo/go-esd/cache/redisclient 是在redis官方包上进行的二次封装。它适用于容器环境,能自动的从容器的环境变量、挂载的配置文件获取参数并创建redis-client实例。方便开发人员
go get github.com/pm-redemption/redis
根据不同的安全需求、运维定制,您有四种方式创建redis-client
//此方法主要应用与测试环境,生产环境不建议使用
import "redis" github.com/pm-redemption/redis
func main() {
// check options.go for more details
opts := redis.RedisClientOptions{
Type: redis.ClientNormal,
Hosts: []string{"localhost:6379"},
Password: "123456",
Database: 0,
}
client := redis.NewRedisClient(opts)
if err := client.Ping().Err(); err != nil {
panic(err)
}
// Using cluster mode
clusterOpts := redis.RedisClientOptions{
Type: redis.ClientCluster,
Hosts: []string{"localhost:7000","localhost:7001","localhost:7002"},
Password: "123456",
Database: 0,
// all keys with a prefix
KeyPrefix: "my-app:",
}
clusterClient := redis.NewRedisClient(clusterOpts)
if err := clusterClient.Ping().Err(); err != nil {
panic(err)
}
}
import redis "github.com/pm-redemption/redis"
func main(){
//RWType:
// OnlyWrite
// OnlyWrite
// ReadAndWrite
r:= redis.OnlyRead
client,err:= redis.AutoConfigRedisClientInEnv(r)
if err!{
panic(err)
}
}
import redis "github.com/pm-redemption/redis"
func main(){
//RWType:
// OnlyWrite
// OnlyWrite
// ReadAndWrite
r:= redis.OnlyRead
client,err:= redis.AutoConfigRedisClientInVolume(r)
if err!{
panic(err)
}
}
import redis "github.com/pm-redemption/redis"
func main(){
//RWType:
// OnlyWrite
// OnlyWrite
// ReadAndWrite
r:= redis.OnlyRead
client,err:= redis.AutoConfigRedisClient(r)
if err!{
panic(err)
}
}
apiVersion: v1
...
spec:
volumes:
- name: redis-secret
secret:
secretName: redis-secret
containers:
....
volumeMounts:
- name: redis-secret
mountPath: "/etc/paas" # it must be this value
readOnly: true
env:
- name: REDIS_TYPE_READER # Injected redis variables must have ENV_PREFIX when ENV_PREFIX is not null
value: "cluster"
- name: REDIS_HOST_READER
value: "1.1.1.1 1.1.1.2 1.1.1.3"
- name: REDIS_PORT_READER
value: "26379 26379 26379"
- name: REDIS_DB_NAME_READER
value: '0'
- name: REDIS_DB_PASSWORD_READER
value: "aiyijing" # redis:passwd
- name: REDIS_MAX_CONNECTIONS_READER
value: "32"
- name: REDIS_KEY_PREFIX_READER
value: "aiyijing_"
- name: REDIS_SKIP_FULL_COVER_CHECK_READER
value: "false"
- name: REDIS_TIMEOUT_READER
value: '5'
apiVersion: v1
kind: Secret
metadata:
name: redis-secret
type: Opaque
data:
# 目前仅支持toml文件
redis.toml: `base64`
# normal为单例,cluster为集群
REDIS_TYPE_READER="cluster"
# ip,集群模式下IP会有多个,以逗号分割,IP数量和端口数量一致
REDIS_HOST_READER=["10.0.129.115","10.0.128.150","10.0.128.89"]
# 端口,集群模式下端口会有多个,以逗号分割,IP数量和端口数量一致
REDIS_PORT_READER=["26379","26379","26379"]
# redis的DB name,只有在单例模式下才管用,集群模式会被忽略
REDIS_DB_NAME_READER=0
# 密码,如果没有密码则传空
REDIS_DB_PASSWORD_READER="alauda_redis_passwd"
# 最大连接数, 默认为32
REDIS_MAX_CONNECTIONS_READER=32
# redis key的前缀
REDIS_KEY_PREFIX_READER="alauda_redis_passwd"
# 当用户屏蔽了CONFIG命令时,需要把这个值改为true,只有集群模式有这个变量
REDIS_SKIP_FULL_COVER_CHECK_READER=false
# redis连接和操作的超时时间为5秒
REDIS_TIMEOUT_READER=5
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.