store

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

func New

func New[T any](init T, ok bool) *Store[T]

Initialize Store

func (*Store[T]) Get

func (s *Store[T]) Get() (T, bool)

Return data

func (*Store[T]) Pop

func (s *Store[T]) Pop() (T, bool)

Return data and set ok to false

func (*Store[T]) Set

func (s *Store[T]) Set(d T)

Set data

func (*Store[T]) TryGet

func (s *Store[T]) TryGet() (T, bool)

The returning boolean value indicates one of the following:

  • TryLock succeeded and data exists
  • TryLock succeeded and data does not exist
  • TryLock failed

func (*Store[T]) TryPop

func (s *Store[T]) TryPop() (T, bool)

func (*Store[T]) TrySet

func (s *Store[T]) TrySet(d T) bool

Return the result of TryLock()

func (*Store[T]) TryUpdate

func (s *Store[T]) TryUpdate(f func(T) T) bool

Return the result of TryLock()

func (*Store[T]) Update

func (s *Store[T]) Update(f func(T) T)

Update data based on the previous Store

Jump to

Keyboard shortcuts

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