store

package
v0.0.0-...-cf576ff Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MapStore

type MapStore struct {
	// contains filtered or unexported fields
}

MapStore represents a simple map storage for the Puppy store

func NewMapStore

func NewMapStore() *MapStore

NewMapStore creates a new in-memory store with map intialised

func (*MapStore) CreatePuppy

func (m *MapStore) CreatePuppy(p puppy.Puppy) error

CreatePuppy saves new puppy if not in store, if it is already returns error

func (*MapStore) DeletePuppy

func (m *MapStore) DeletePuppy(id int16) error

DeletePuppy deletes a puppy by id from the store

func (*MapStore) ReadPuppy

func (m *MapStore) ReadPuppy(id int16) (puppy.Puppy, error)

ReadPuppy reads store by Puppy ID

func (*MapStore) UpdatePuppy

func (m *MapStore) UpdatePuppy(id int16, p *puppy.Puppy) error

UpdatePuppy updates puppy with new value if ID present otherwise error

type SyncStore

type SyncStore struct {
	sync.Mutex
	sync.Map
}

SyncStore implementation of the Storer interface

func NewSyncStore

func NewSyncStore() *SyncStore

NewSyncStore creates a new in-memory store with map intialised

func (*SyncStore) CreatePuppy

func (s *SyncStore) CreatePuppy(p puppy.Puppy) error

CreatePuppy saves new puppy if not in store, if it is already returns error

func (*SyncStore) DeletePuppy

func (s *SyncStore) DeletePuppy(id int16) error

DeletePuppy deletes a puppy from the store

func (*SyncStore) ReadPuppy

func (s *SyncStore) ReadPuppy(id int16) (puppy.Puppy, error)

ReadPuppy gets a puppy from the store given an ID

func (*SyncStore) String

func (s *SyncStore) String() string

func (*SyncStore) UpdatePuppy

func (s *SyncStore) UpdatePuppy(id int16, p *puppy.Puppy) error

UpdatePuppy puts new puppy data to the store, error if id does not exist

Jump to

Keyboard shortcuts

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