Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v0.0.44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Update *Update
	Delete []string
}

type Client

type Client interface {
	// Create a cache
	Create(ctx context.Context, name string, ephemeral bool, cached bool) error
	// List caches
	List(ctx context.Context) ([]string, error)
	// Delete delete cache or cache candidate
	Delete(ctx context.Context, name string) error
	// Exists check if cache instance exists
	Exists(ctx context.Context, name string) (bool, error)
	// CreateCandidate create a candidate
	CreateCandidate(ctx context.Context, name, candidate, owner string, priority int32) error
	// GetCandidates get list of candidates
	GetCandidates(ctx context.Context, name string) ([]*cache.CandidateDetails, error)
	// HasCandidate check if a candidate exists
	HasCandidate(ctx context.Context, name, candidate string) (bool, error)
	// DeleteCandidate deletes a candidate
	DeleteCandidate(ctx context.Context, name, candidate string) error
	// Clone a cache
	Clone(ctx context.Context, name, clone string) error
	// CreatePruneID
	CreatePruneID(ctx context.Context, name string, force bool) (string, error)
	// ApplyPrune
	ApplyPrune(ctx context.Context, name, id string) error
	// Modify send a stream of modifications (update or delete) to a cache, or candidate
	Modify(ctx context.Context, name string, opts *Opts, dels [][]string, upds []*Update) error
	// Read from a cache or candidate
	Read(ctx context.Context, name string, opts *Opts, paths [][]string, period time.Duration) []*Update
	// ReadCh read from a cache or candidate, get results through a channel
	ReadCh(ctx context.Context, name string, opts *Opts, paths [][]string, period time.Duration) chan *Update
	// GetChanges present in a candidate
	GetChanges(ctx context.Context, name, candidate string) ([]*Change, error)
	// Discard changes made to a candidate
	Discard(ctx context.Context, name, candidate string) error
	// Commit a candidate changes into the intended store
	Commit(ctx context.Context, name, candidate string) error
	// NewUpdate build a cache update from a sdcpb.Update
	NewUpdate(*sdcpb.Update) (*Update, error)
	// GetKeys retrieve the Keys of the specified store
	GetKeys(ctx context.Context, name string, store cachepb.Store) (chan *Update, error)
	// disconnect from the cache
	Close() error
}

func NewLocalCache

func NewLocalCache(cfg *config.CacheConfig) (Client, error)

func NewRemoteCache

func NewRemoteCache(ctx context.Context, addr string) (Client, error)

type IntentMeta added in v0.0.39

type IntentMeta struct {
	Owner    string
	Priority int32
	Ts       int64
}

type KeyData added in v0.0.39

type KeyData struct {
	Path    []string
	Intents []IntentMeta
}

type Opts

type Opts struct {
	Store         cachepb.Store
	Owner         string // represents the intent name
	Priority      int32
	PriorityCount uint64
	KeysOnly      bool
}

type Update

type Update struct {
	// contains filtered or unexported fields
}

func NewUpdate added in v0.0.39

func NewUpdate(path []string, value []byte, priority int32, owner string, ts int64) *Update

func (*Update) Bytes

func (u *Update) Bytes() []byte

func (*Update) EqualSkipPath added in v0.0.39

func (u *Update) EqualSkipPath(other *Update) bool

EqualSkipPath checks the equality of two updates. It however skips comparing paths and timestamps. This is a shortcut for performace, for cases in which it is already clear that the path is definately equal.

func (*Update) GetPath

func (u *Update) GetPath() []string

func (*Update) Owner

func (u *Update) Owner() string

func (*Update) Priority

func (u *Update) Priority() int32

func (*Update) String added in v0.0.39

func (u *Update) String() string

func (*Update) TS

func (u *Update) TS() int64

func (*Update) Value

func (u *Update) Value() (*sdcpb.TypedValue, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL