mapstruct

package
v0.0.0-...-cea7fe2 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMapStruct

func NewMapStruct(initialData map[string]Data) storage.Storage

NewMapStruct generate new MapStruct

Types

type Data

type Data struct {
	Value      interface{}
	Expiration int64
}

Data struct define structure of saved data

type MapStruct

type MapStruct struct {
	Data map[string]Data
	Mu   sync.RWMutex
}

MapStruct is storage engine that store data into list of structs

func (*MapStruct) Delete

func (store *MapStruct) Delete(key string) (interface{}, error)

Delete return deleted value or error if any problems happen

func (*MapStruct) Exists

func (store *MapStruct) Exists(key string) bool

Exists return true if data exists or false if doesn't

func (*MapStruct) Get

func (store *MapStruct) Get(key string) (value interface{}, err error)

Get return value with inserted key if this key doesn't exists, return error

func (*MapStruct) GetSize

func (store *MapStruct) GetSize() uint

GetSize return how many datum in storage

func (*MapStruct) Set

func (store *MapStruct) Set(key string, val interface{}, t time.Duration) error

Set to add data into storage and return error if any problems happen

func (*MapStruct) SetExpired

func (store *MapStruct) SetExpired(key string, t time.Duration) (interface{}, error)

Jump to

Keyboard shortcuts

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