MCPcopy
hub / github.com/redis/go-redis / ScriptExists

Method ScriptExists

osscluster_commands.go:71–109  ·  view source on GitHub ↗
(ctx context.Context, hashes ...string)

Source from the content-addressed store, hash-verified

69}
70
71func (c *ClusterClient) ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd {
72 args := make([]interface{}, 2+len(hashes))
73 args[0] = "script"
74 args[1] = "exists"
75 for i, hash := range hashes {
76 args[2+i] = hash
77 }
78 cmd := NewBoolSliceCmd(ctx, args...)
79
80 result := make([]bool, len(hashes))
81 for i := range result {
82 result[i] = true
83 }
84
85 _ = c.withProcessHook(ctx, cmd, func(ctx context.Context, _ Cmder) error {
86 var mu sync.Mutex
87 err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error {
88 val, err := shard.ScriptExists(ctx, hashes...).Result()
89 if err != nil {
90 return err
91 }
92
93 mu.Lock()
94 for i, v := range val {
95 result[i] = result[i] && v
96 }
97 mu.Unlock()
98
99 return nil
100 })
101 if err != nil {
102 cmd.SetErr(err)
103 } else {
104 cmd.val = result
105 }
106 return nil
107 })
108 return cmd
109}

Callers

nothing calls this directly

Calls 6

ForEachShardMethod · 0.95
NewBoolSliceCmdFunction · 0.85
withProcessHookMethod · 0.80
ResultMethod · 0.65
ScriptExistsMethod · 0.65
SetErrMethod · 0.65

Tested by

no test coverage detected