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.

41 lines
641 B

  1. package redis
  2. import (
  3. redisdb "github.com/gomodule/redigo/redis"
  4. )
  5. /**
  6. * key增加
  7. */
  8. func Incrby(key string, value interface{}) (int64, error) {
  9. c := GetConn()
  10. var err error
  11. var reply interface{}
  12. reply, err = c.Do("INCRBY", key, value)
  13. CloseConn(c)
  14. if err != nil {
  15. return 0, err
  16. }
  17. ret, err := redisdb.Int64(reply, err)
  18. return ret, err
  19. }
  20. /**
  21. * key减
  22. */
  23. func Decrby(key string, value interface{}) (int64, error) {
  24. c := GetConn()
  25. var err error
  26. var reply interface{}
  27. reply, err = c.Do("DECRBY", key, value)
  28. CloseConn(c)
  29. if err != nil {
  30. return 0, err
  31. }
  32. ret, err := redisdb.Int64(reply, err)
  33. return ret, err
  34. }