(ctx context.Context, c Scripter)
| 69 | } |
| 70 | |
| 71 | func (s *Script) Exists(ctx context.Context, c Scripter) *BoolSliceCmd { |
| 72 | s.mu.RLock() |
| 73 | hash := s.hash |
| 74 | serverSHA := s.serverSHA |
| 75 | s.mu.RUnlock() |
| 76 | if hash == "" && serverSHA { |
| 77 | // For server-side scripts, obtain digest from Redis first. |
| 78 | // If hash is empty, it means SCRIPT LOAD was not called yet, so we check existence of empty hash which will return false. |
| 79 | // This avoids unnecessary SCRIPT LOAD just to check existence. |
| 80 | if err := s.ensureHash(ctx, c); err != nil { |
| 81 | return c.ScriptExists(ctx, "") |
| 82 | } |
| 83 | s.mu.RLock() |
| 84 | hash = s.hash |
| 85 | s.mu.RUnlock() |
| 86 | } |
| 87 | if hash == "" { |
| 88 | return c.ScriptExists(ctx, "") |
| 89 | } |
| 90 | return c.ScriptExists(ctx, hash) |
| 91 | } |
| 92 | |
| 93 | func (s *Script) Eval(ctx context.Context, c Scripter, keys []string, args ...interface{}) *Cmd { |
| 94 | return c.Eval(ctx, s.src, keys, args...) |
nothing calls this directly
no test coverage detected