feat: .env.example

This commit is contained in:
sittichok Ouamsiri
2026-06-15 21:45:29 +07:00
parent bea934fc14
commit 9b550f4be2
4 changed files with 42 additions and 6 deletions
+2 -2
View File
@@ -17,13 +17,13 @@ type Cache struct {
prefix string
}
func New(ctx context.Context, addr, password string, db int) (*Cache, error) {
func New(ctx context.Context, addr, password string, db int, keyPrefix string) (*Cache, error) {
rdb := redis.NewClient(&redis.Options{Addr: addr, Password: password, DB: db})
if err := rdb.Ping(ctx).Err(); err != nil {
_ = rdb.Close()
return nil, err
}
return &Cache{rdb: rdb, prefix: "code:"}, nil
return &Cache{rdb: rdb, prefix: keyPrefix + "code:"}, nil
}
func (c *Cache) key(code string) string { return c.prefix + code }