mirror of
https://github.com/ThisTine/Snip.git
synced 2026-08-18 23:18:47 +07:00
feat: .env.example
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user