store

package
v0.0.0-...-bef2813 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database[T any] interface {
	Persist() error
	Retrieve() error

	Create(table string, data *Table[T])
	ReadOrCreate(table string) *Table[T]
}

func NewGobDatabase

func NewGobDatabase[T any](file string) Database[T]

type GobDatabase

type GobDatabase[T any] struct {
	File string
	// contains filtered or unexported fields
}

func (*GobDatabase[T]) Create

func (db *GobDatabase[T]) Create(table string, data *Table[T])

func (*GobDatabase[T]) Persist

func (db *GobDatabase[T]) Persist() error

func (*GobDatabase[T]) ReadOrCreate

func (db *GobDatabase[T]) ReadOrCreate(table string) *Table[T]

func (*GobDatabase[T]) Retrieve

func (db *GobDatabase[T]) Retrieve() error

type Table

type Table[T any] struct {
	Data map[string]T
	// contains filtered or unexported fields
}

func NewTable

func NewTable[T any]() *Table[T]

func (*Table[T]) Get

func (t *Table[T]) Get(key string) T

func (*Table[T]) Init

func (t *Table[T]) Init()

func (*Table[T]) Lock

func (t *Table[T]) Lock()

func (*Table[T]) Set

func (t *Table[T]) Set(key string, value T)

func (*Table[T]) Unlock

func (t *Table[T]) Unlock()