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.

43 line
1.0 KiB

  1. package redis
  2. import "context"
  3. type HyperLogLogCmdable interface {
  4. PFAdd(ctx context.Context, key string, els ...interface{}) *IntCmd
  5. PFCount(ctx context.Context, keys ...string) *IntCmd
  6. PFMerge(ctx context.Context, dest string, keys ...string) *StatusCmd
  7. }
  8. func (c cmdable) PFAdd(ctx context.Context, key string, els ...interface{}) *IntCmd {
  9. args := make([]interface{}, 2, 2+len(els))
  10. args[0] = "pfadd"
  11. args[1] = key
  12. args = appendArgs(args, els)
  13. cmd := NewIntCmd(ctx, args...)
  14. _ = c(ctx, cmd)
  15. return cmd
  16. }
  17. func (c cmdable) PFCount(ctx context.Context, keys ...string) *IntCmd {
  18. args := make([]interface{}, 1+len(keys))
  19. args[0] = "pfcount"
  20. for i, key := range keys {
  21. args[1+i] = key
  22. }
  23. cmd := NewIntCmd(ctx, args...)
  24. _ = c(ctx, cmd)
  25. return cmd
  26. }
  27. func (c cmdable) PFMerge(ctx context.Context, dest string, keys ...string) *StatusCmd {
  28. args := make([]interface{}, 2+len(keys))
  29. args[0] = "pfmerge"
  30. args[1] = dest
  31. for i, key := range keys {
  32. args[2+i] = key
  33. }
  34. cmd := NewStatusCmd(ctx, args...)
  35. _ = c(ctx, cmd)
  36. return cmd
  37. }