store

package module
v0.0.0-...-258e649 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug() bool

Debug toggles (enables/disables) debug output through Logger and returns either true if enabled or respectively false if disabled.

func Type

func Type(data any) reflect.Kind

Type determines the type of given data and returns the kind value.

Types

type Content

type Content struct {
	Name any
	Data any
	Date time.Time
}

Content contains the actual data.

type List

type List []summary

List is replied on List() calls with metadata.

type Snapshot

type Snapshot struct {
	Date time.Time
	Data []*Content
}

Snapshot contains the exported data and a timestamp of creation.

type Store

type Store struct {
	// Logger adds a prefix of "store: " by default.
	Logger *log.Logger
	// contains filtered or unexported fields
}

Store is the main datatype that holds runtime.

func New

func New() *Store

New creates a new instance of store.

func (*Store) Delete

func (s *Store) Delete(key any) bool

Delete removes the item called by the given key and return true if the key existed.

func (*Store) Export

func (s *Store) Export() *Snapshot

Export allows snapshots of store.

func (*Store) Get

func (s *Store) Get(key any) (any, bool)

Get looks up items by the given key and returns the data and a found boolean.

func (*Store) Import

func (s *Store) Import(snap *Snapshot) *Store

Import will simply add snapshot data to store.

func (*Store) List

func (s *Store) List() List

List returns all keys with corresponding last change date values in the store.

func (*Store) Set

func (s *Store) Set(key, data any) bool

Set adds a new or overwrites an existing item in the store with the given key and data and returns the boolean value of replace.

func (*Store) State

func (s *Store) State(key any) (time.Time, bool)

State looks up the item by the given key and returns the change date and a found boolean.

Jump to

Keyboard shortcuts

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