Files
argo-cd/util/cache/client.go
Matthieu MOREL 9ea979bbcd chore: enable use-any from revive (#21282)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-01-02 18:26:59 -05:00

38 lines
810 B
Go

package cache
import (
"context"
"errors"
"time"
)
var (
ErrCacheMiss = errors.New("cache: key is missing")
ErrCacheKeyLocked = errors.New("cache: key is locked")
CacheLockedValue = "locked"
)
type Item struct {
Key string
Object any
CacheActionOpts CacheActionOpts
}
type CacheActionOpts struct {
// Delete item from cache
Delete bool
// Disable writing if key already exists (NX)
DisableOverwrite bool
// Expiration is the cache expiration time.
Expiration time.Duration
}
type CacheClient interface {
Set(item *Item) error
Rename(oldKey string, newKey string, expiration time.Duration) error
Get(key string, obj any) error
Delete(key string) error
OnUpdated(ctx context.Context, key string, callback func() error) error
NotifyUpdated(key string) error
}