⚠️ WIP migrating tmp to patch

This commit is contained in:
pakintada@gmail.com 2024-02-22 16:04:34 +07:00
parent 89ce1f361c
commit fed315367a
13 changed files with 317 additions and 270 deletions

View file

@ -135,3 +135,39 @@ func (r *RedisCli) SetKeyTimeout(key string, value interface{}, timeout int) err
fmt.Println("error on EXPIRE ", err)
return err
}
func (r *RedisCli) KeyList() ([]string, error) {
// if cannot pass healthcheck, return err
if err := r.HealthCheck(); err != nil {
fmt.Println("HS> KEYS error ", err)
return nil, err
}
keys := r.Client.Keys(context.Background(), "*")
return keys.Result()
}
// list operations
func (r *RedisCli) GetList(key string) ([]string, error) {
// if cannot pass healthcheck, return err
if err := r.HealthCheck(); err != nil {
fmt.Println("HS> List.GET error ", err)
return nil, err
}
return r.Client.LRange(context.Background(), key, 0, -1).Result()
}
func (r *RedisCli) Add(key string, value interface{}) error {
// if cannot pass healthcheck, return err
if err := r.HealthCheck(); err != nil {
fmt.Println("HS> List.ADD error ", err)
return err
}
err := r.Client.RPush(context.Background(), key, value)
return err.Err()
}