store

package module
v0.0.0-...-7f3958b Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: BSD-3-Clause Imports: 5 Imported by: 1

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) GetBool

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

GetBool looks up items by the given key and returns the data as boolean.

func (*Store) GetBools

func (s *Store) GetBools(key any) []bool

GetBools looks up items by the given key and returns the data as []bool.

func (*Store) GetByte

func (s *Store) GetByte(key any) byte

GetByte looks up items by the given key and returns the data as byte.

func (*Store) GetBytes

func (s *Store) GetBytes(key any) []byte

GetBytes looks up items by the given key and returns the data as []byte.

func (*Store) GetFloat64

func (s *Store) GetFloat64(key any) float64

GetFloat64 looks up items by the given key and returns the data as float64.

func (*Store) GetFloat64s

func (s *Store) GetFloat64s(key any) []float64

GetFloat64s looks up items by the given key and returns the data as []float64.

func (*Store) GetInt

func (s *Store) GetInt(key any) int

GetInt looks up items by the given key and returns the data as int.

func (*Store) GetInt64

func (s *Store) GetInt64(key any) int64

GetInt64 looks up items by the given key and returns the data as int64.

func (*Store) GetInt64s

func (s *Store) GetInt64s(key any) []int64

GetInt64s looks up items by the given key and returns the data as []int64.

func (*Store) GetInts

func (s *Store) GetInts(key any) []int

GetInts looks up items by the given key and returns the data as []int.

func (*Store) GetString

func (s *Store) GetString(key any) string

GetString looks up items by the given key and returns the data as string.

func (*Store) GetStrings

func (s *Store) GetStrings(key any) []string

GetStrings looks up items by the given key and returns the data as []string.

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.

type Summary

type Summary struct {
	Key  any
	Date time.Time
}

Jump to

Keyboard shortcuts

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