model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheBucket

type CacheBucket interface {
	Name() string
	Docs(keys []string) []CacheDoc
	Values(keys []string) []any
	Update(key string, data any) CacheDoc
	// UpdateWithTs return doc and flag to indicate if data is updated or not
	UpdateWithTs(key string, data any, ts time.Time) (CacheDoc, bool)
	//Filter return all keys that match the given label filters
	Filter(labelFilters ...[]string) []string
	// Scan return all keys that match the given pattern
	Scan(match string) []string
	Remove(keys []string) []CacheDoc
	Clear()
	Delete()
	GetLastErrors() []error
}

type CacheClient

type CacheClient interface {
	WithBucket(CacheBucket) CacheBucket
	Bucket(name string) CacheBucket
	Buckets() []CacheBucket
	RemoveBucket(bktName string)

	Collection(name string) CacheCollection
	Collections() []CacheCollection
	RemoveCollection(name string)
}

type CacheCollection

type CacheCollection interface {
	Name() string
	Keys() []string
	MembersMap(key string) MembersMap
	MembersMaps(keys []string) []MembersMap
	Add(key string, members []string)
	Remove(key string, members []string)
	Clear(key string)
	ClearAll()
	Delete()
	GetLastErrors() []error
}

type CacheDoc

type CacheDoc interface {
	CacheTime
	CacheExpire
	Key() string
	Val() any
	SetValue(val any) CacheDoc
	Labels() LabelSet
	AddLabels(labels []string) LabelSet
	RemoveLabels(label []string) LabelSet
	Delete()
}

type CacheExpire

type CacheExpire interface {
	Expire(d time.Duration, onExpire func(CacheDoc))
}

type CacheTime

type CacheTime interface {
	WithTime(ts time.Time) CacheDoc
	// SetValueWithTs returns doc and flag(value is updated or not)
	SetValueWithTs(val any, ts time.Time) (CacheDoc, bool)
	Time() time.Time
}

type Coder

type Coder interface {
	Encoder
	Decoder
}

type Decoder

type Decoder interface {
	Decode(data string, out any) error
}

type Encoder

type Encoder interface {
	Encode(data any) (string, error)
}

type LabelSet

type LabelSet map[string]bool

func (LabelSet) CheckAnd

func (ls LabelSet) CheckAnd(labels []string) bool

func (LabelSet) CheckOr

func (ls LabelSet) CheckOr(labels []string) bool

func (LabelSet) Copy

func (ls LabelSet) Copy() LabelSet

func (LabelSet) Format

func (ls LabelSet) Format() string

func (LabelSet) From

func (ls LabelSet) From(labels []string) LabelSet

func (LabelSet) FromStr

func (ls LabelSet) FromStr(labels string) LabelSet

func (LabelSet) List

func (ls LabelSet) List() []string

type Logger

type Logger interface {
	// Debug logs a debug message with optional key-value pairs
	Debug(msg string, keysAndValues ...any)
	// Info logs an informational message with optional key-value pairs
	Info(msg string, keysAndValues ...any)
	// Error logs an error message with optional key-value pairs
	Error(msg string, keysAndValues ...any)
	// Fatal logs an error message and then panics
	// This is used for critical errors that should stop execution
	Fatal(msg string, keysAndValues ...any)
}

Logger is an interface for logging in the cache system. Users can provide their own implementation to integrate with their logging framework.

type MembersMap

type MembersMap map[string]struct{}

func (MembersMap) Exists

func (smm MembersMap) Exists(mem string) bool

func (MembersMap) List

func (smm MembersMap) List() []string

Jump to

Keyboard shortcuts

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