cache

package
v0.0.0-...-e9cdb27 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(ml *memberlist.Memberlist, opts Options) *Cache

New uses an existing memberlist. Caller owns ml.

func NewWithConfig

func NewWithConfig(cfg *memberlist.Config, opts Options) (*Cache, error)

func (*Cache) Close

func (c *Cache) Close()

func (*Cache) Delete

func (c *Cache) Delete(key string)

func (*Cache) Get

func (c *Cache) Get(key string) ([]byte, bool)

func (*Cache) GetBroadcasts

func (c *Cache) GetBroadcasts(overhead, limit int) [][]byte

func (*Cache) LocalState

func (c *Cache) LocalState(join bool) []byte

func (*Cache) Memberlist

func (c *Cache) Memberlist() *memberlist.Memberlist

Memberlist uses the underlying memberlist

func (*Cache) MergeRemoteState

func (c *Cache) MergeRemoteState(buf []byte, join bool)

func (*Cache) NodeMeta

func (c *Cache) NodeMeta(limit int) []byte

func (*Cache) NotifyMsg

func (c *Cache) NotifyMsg(b []byte)

func (*Cache) Set

func (c *Cache) Set(key string, value []byte, ttl time.Duration)

type Entry

type Entry struct {
	Value     []byte
	Version   uint64    // last right wins prim clock
	ExpireAt  time.Time // zero default = no ttl
	Tombstone bool      // true == deleted
	OriginID  string    // Comparison for tiebreaker
}

Entry is the local KV state.

type GossipMessage

type GossipMessage struct {
	Key       string
	Value     []byte
	Version   uint64
	ExpireAt  time.Time
	Tombstone bool
	// Tie-break when versions collide
	OriginID string // stable node ID  UUID or addr
}

GossipMessage is the wire format.

type Options

type Options struct {
	OriginID       string
	RetransmitMult int
	SweepInterval  time.Duration

	// Adaptive gossip options
	AdaptiveGossip bool
	DecayInterval  time.Duration
	GossipFloor    time.Duration

	// Explicit rate thresholds
	HighRateThreshold   int64 // Messages/sec for aggressive gossip (default 50)
	MediumRateThreshold int64 // Messages/sec for normal gossip (default 10)
	LowRateThreshold    int64 // Messages/sec for probabilistic gossip (default 1)
}

Jump to

Keyboard shortcuts

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