forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go: Add command ZScan (valkey-io#2950)
* Go: Add command ZScan Signed-off-by: TJ Zhang <tj.zhang@improving.com>
- Loading branch information
1 parent
a2b9d20
commit dbb83b6
Showing
5 changed files
with
301 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
|
||
package options | ||
|
||
// This struct represents the optional arguments for the ZSCAN command. | ||
type ZScanOptions struct { | ||
BaseScanOptions | ||
noScores bool | ||
} | ||
|
||
func NewZScanOptionsBuilder() *ZScanOptions { | ||
return &ZScanOptions{} | ||
} | ||
|
||
// SetNoScores sets the noScores flag for the ZSCAN command. | ||
// If this value is set to true, the ZSCAN command will be called with NOSCORES option. | ||
// In the NOSCORES option, scores are not included in the response. | ||
func (zScanOptions *ZScanOptions) SetNoScores(noScores bool) *ZScanOptions { | ||
zScanOptions.noScores = noScores | ||
return zScanOptions | ||
} | ||
|
||
// SetMatch sets the match pattern for the ZSCAN command. | ||
func (zScanOptions *ZScanOptions) SetMatch(match string) *ZScanOptions { | ||
zScanOptions.BaseScanOptions.SetMatch(match) | ||
return zScanOptions | ||
} | ||
|
||
// SetCount sets the count of the ZSCAN command. | ||
func (zScanOptions *ZScanOptions) SetCount(count int64) *ZScanOptions { | ||
zScanOptions.BaseScanOptions.SetCount(count) | ||
return zScanOptions | ||
} | ||
|
||
func (options *ZScanOptions) ToArgs() ([]string, error) { | ||
args := []string{} | ||
baseArgs, err := options.BaseScanOptions.ToArgs() | ||
args = append(args, baseArgs...) | ||
|
||
if options.noScores { | ||
args = append(args, NoScores) | ||
} | ||
return args, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters