github.com/argoproj/argo-cd/v3@v3.2.1/util/cache/client.go (about)

     1  package cache
     2  
     3  import (
     4  	"context"
     5  	"errors"
     6  	"time"
     7  )
     8  
     9  var (
    10  	ErrCacheMiss      = errors.New("cache: key is missing")
    11  	ErrCacheKeyLocked = errors.New("cache: key is locked")
    12  	CacheLockedValue  = "locked"
    13  )
    14  
    15  type Item struct {
    16  	Key             string
    17  	Object          any
    18  	CacheActionOpts CacheActionOpts
    19  }
    20  
    21  type CacheActionOpts struct {
    22  	// Delete item from cache
    23  	Delete bool
    24  	// Disable writing if key already exists (NX)
    25  	DisableOverwrite bool
    26  	// Expiration is the cache expiration time.
    27  	Expiration time.Duration
    28  }
    29  
    30  type CacheClient interface {
    31  	Set(item *Item) error
    32  	Rename(oldKey string, newKey string, expiration time.Duration) error
    33  	Get(key string, obj any) error
    34  	Delete(key string) error
    35  	OnUpdated(ctx context.Context, key string, callback func() error) error
    36  	NotifyUpdated(key string) error
    37  }