redis rpc服务, 提供redis操作方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
455 B

  1. package redisrpc
  2. import (
  3. "github.com/golang/protobuf/proto"
  4. )
  5. /**
  6. * 使用用户名查询
  7. */
  8. func SetExpire(key string, ttl int64, url ...string) (int64, error) {
  9. conn, _, err := Conn(url...)
  10. if err != nil {
  11. return 0, err
  12. }
  13. defer conn.Close()
  14. req := &SetExpireRequest{proto.String(key), proto.Int64(ttl), nil}
  15. res := &SetExpireResponse{}
  16. err = conn.SetExpire(req, res)
  17. if err != nil {
  18. return 0, err
  19. }
  20. return res.GetRet(), nil
  21. }