syncx

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 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 Map

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewMap

func NewMap[K comparable, V any]() Map[K, V]

func (Map[K, V]) Delete

func (m Map[K, V]) Delete(item K)

func (Map[K, V]) Get

func (m Map[K, V]) Get(item K) (res V, ok bool)

func (Map[K, V]) Has

func (m Map[K, V]) Has(item K) bool

func (Map[K, V]) Keys added in v1.14.0

func (m Map[K, V]) Keys() []K

func (Map[K, V]) Put

func (m Map[K, V]) Put(key K, val V)

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T comparable]() Set[T]

func (Set[T]) Add

func (s Set[T]) Add(item T)

func (Set[T]) Delete

func (s Set[T]) Delete(item T)

func (Set[T]) Has

func (s Set[T]) Has(item T) bool

type TTLValue

type TTLValue[T any] struct {
	// contains filtered or unexported fields
}

TTLValue is a simple cached value with expiration time.

func NewTTLValue

func NewTTLValue[T any](ttl time.Duration, initialValue T) *TTLValue[T]

NewTTLValue constructs a new TTLValue

func (*TTLValue[T]) Get

func (v *TTLValue[T]) Get() (result T)

Get returns stored value.

Returns default empty value if TTL expired.

func (*TTLValue[T]) Set

func (v *TTLValue[T]) Set(newValue T)

Set sets a new value and updates expiration time.

Jump to

Keyboard shortcuts

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