本站源代码
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.

141 satır
3.7KB

  1. package redis
  2. import "time"
  3. // NewCmdResult returns a Cmd initialised with val and err for testing
  4. func NewCmdResult(val interface{}, err error) *Cmd {
  5. var cmd Cmd
  6. cmd.val = val
  7. cmd.setErr(err)
  8. return &cmd
  9. }
  10. // NewSliceResult returns a SliceCmd initialised with val and err for testing
  11. func NewSliceResult(val []interface{}, err error) *SliceCmd {
  12. var cmd SliceCmd
  13. cmd.val = val
  14. cmd.setErr(err)
  15. return &cmd
  16. }
  17. // NewStatusResult returns a StatusCmd initialised with val and err for testing
  18. func NewStatusResult(val string, err error) *StatusCmd {
  19. var cmd StatusCmd
  20. cmd.val = val
  21. cmd.setErr(err)
  22. return &cmd
  23. }
  24. // NewIntResult returns an IntCmd initialised with val and err for testing
  25. func NewIntResult(val int64, err error) *IntCmd {
  26. var cmd IntCmd
  27. cmd.val = val
  28. cmd.setErr(err)
  29. return &cmd
  30. }
  31. // NewDurationResult returns a DurationCmd initialised with val and err for testing
  32. func NewDurationResult(val time.Duration, err error) *DurationCmd {
  33. var cmd DurationCmd
  34. cmd.val = val
  35. cmd.setErr(err)
  36. return &cmd
  37. }
  38. // NewBoolResult returns a BoolCmd initialised with val and err for testing
  39. func NewBoolResult(val bool, err error) *BoolCmd {
  40. var cmd BoolCmd
  41. cmd.val = val
  42. cmd.setErr(err)
  43. return &cmd
  44. }
  45. // NewStringResult returns a StringCmd initialised with val and err for testing
  46. func NewStringResult(val string, err error) *StringCmd {
  47. var cmd StringCmd
  48. cmd.val = val
  49. cmd.setErr(err)
  50. return &cmd
  51. }
  52. // NewFloatResult returns a FloatCmd initialised with val and err for testing
  53. func NewFloatResult(val float64, err error) *FloatCmd {
  54. var cmd FloatCmd
  55. cmd.val = val
  56. cmd.setErr(err)
  57. return &cmd
  58. }
  59. // NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing
  60. func NewStringSliceResult(val []string, err error) *StringSliceCmd {
  61. var cmd StringSliceCmd
  62. cmd.val = val
  63. cmd.setErr(err)
  64. return &cmd
  65. }
  66. // NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing
  67. func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd {
  68. var cmd BoolSliceCmd
  69. cmd.val = val
  70. cmd.setErr(err)
  71. return &cmd
  72. }
  73. // NewStringStringMapResult returns a StringStringMapCmd initialised with val and err for testing
  74. func NewStringStringMapResult(val map[string]string, err error) *StringStringMapCmd {
  75. var cmd StringStringMapCmd
  76. cmd.val = val
  77. cmd.setErr(err)
  78. return &cmd
  79. }
  80. // NewStringIntMapCmdResult returns a StringIntMapCmd initialised with val and err for testing
  81. func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd {
  82. var cmd StringIntMapCmd
  83. cmd.val = val
  84. cmd.setErr(err)
  85. return &cmd
  86. }
  87. // NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing
  88. func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd {
  89. var cmd ZSliceCmd
  90. cmd.val = val
  91. cmd.setErr(err)
  92. return &cmd
  93. }
  94. // NewScanCmdResult returns a ScanCmd initialised with val and err for testing
  95. func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd {
  96. var cmd ScanCmd
  97. cmd.page = keys
  98. cmd.cursor = cursor
  99. cmd.setErr(err)
  100. return &cmd
  101. }
  102. // NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing
  103. func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd {
  104. var cmd ClusterSlotsCmd
  105. cmd.val = val
  106. cmd.setErr(err)
  107. return &cmd
  108. }
  109. // NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing
  110. func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd {
  111. var cmd GeoLocationCmd
  112. cmd.locations = val
  113. cmd.setErr(err)
  114. return &cmd
  115. }
  116. // NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing
  117. func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd {
  118. var cmd CommandsInfoCmd
  119. cmd.val = val
  120. cmd.setErr(err)
  121. return &cmd
  122. }
上海开阖软件有限公司 沪ICP备12045867号-1