mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
38 lines
810 B
Go
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
|
|
}
|