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

Method EvalShaRO

script.go:161–189  ·  view source on GitHub ↗
(ctx context.Context, c Scripter, keys []string, args ...interface{})

Source from the content-addressed store, hash-verified

159}
160
161func (s *Script) EvalShaRO(ctx context.Context, c Scripter, keys []string, args ...interface{}) *Cmd {
162 if !s.serverSHA {
163 s.mu.RLock()
164 hash := s.hash
165 s.mu.RUnlock()
166 return c.EvalShaRO(ctx, hash, keys, args...)
167 }
168
169 if err := s.ensureHash(ctx, c); err != nil {
170 return s.EvalRO(ctx, c, keys, args...)
171 }
172
173 s.mu.RLock()
174 hash := s.hash
175 s.mu.RUnlock()
176
177 r := c.EvalShaRO(ctx, hash, keys, args...)
178 if HasErrorPrefix(r.Err(), "NOSCRIPT") {
179 if err := s.ensureHash(ctx, c); err != nil {
180 return s.EvalRO(ctx, c, keys, args...)
181 }
182 s.mu.RLock()
183 hash = s.hash
184 s.mu.RUnlock()
185 return c.EvalShaRO(ctx, hash, keys, args...)
186 }
187
188 return r
189}
190
191// Run optimistically uses EVALSHA to run the script. If script does not exist
192// it is retried using EVAL.

Callers 1

RunROMethod · 0.95

Calls 5

ensureHashMethod · 0.95
EvalROMethod · 0.95
HasErrorPrefixFunction · 0.85
EvalShaROMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected