MCPcopy Create free account
hub / github.com/cortexproject/cortex / CAS

Method CAS

pkg/ring/kv/multi.go:305–320  ·  view source on GitHub ↗

CAS is a part of kv.Client interface.

(ctx context.Context, key string, f func(in any) (out any, retry bool, err error))

Source from the content-addressed store, hash-verified

303
304// CAS is a part of kv.Client interface.
305func (m *MultiClient) CAS(ctx context.Context, key string, f func(in any) (out any, retry bool, err error)) error {
306 _, kv := m.getPrimaryClient()
307
308 updatedValue := any(nil)
309 err := kv.client.CAS(ctx, key, func(in any) (any, bool, error) {
310 out, retry, err := f(in)
311 updatedValue = out
312 return out, retry, err
313 })
314
315 if err == nil && updatedValue != nil && m.mirroringEnabled.Load() {
316 m.writeToSecondary(ctx, kv, key, updatedValue)
317 }
318
319 return err
320}
321
322// WatchKey is a part of kv.Client interface.
323func (m *MultiClient) WatchKey(ctx context.Context, key string, f func(any) bool) {

Callers

nothing calls this directly

Calls 4

getPrimaryClientMethod · 0.95
writeToSecondaryMethod · 0.95
LoadMethod · 0.80
CASMethod · 0.65

Tested by

no test coverage detected