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 is map based implementation of Storer interface

func NewMapStore

func NewMapStore() *MapStore

NewMapStore creates a new MapStore

func (*MapStore) CreatePuppy

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

CreatePuppy inserts given puppy in store and returns given id to the puppy Will return an error if value of puppy is negative

func (*MapStore) DeletePuppy

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

DeletePuppy deletes puppy with given id from store Returns nil if puppy with given id exists. Otherwise returns an errorZ

func (*MapStore) ReadPuppy

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

ReadPuppy reads puppy with given id from the store Will return an error if puppy with given id does not exist

func (*MapStore) UpdatePuppy

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

UpdatePuppy update puppy with given id in store if puppy exists Returns nil if puppy with given id exists. Otherwise returns an error

type SyncStore

type SyncStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SyncStore is sync.Map based implementation of Storer interface

func NewSyncStore

func NewSyncStore() *SyncStore

NewSyncStore creates a new SyncStore

func (*SyncStore) CreatePuppy

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

CreatePuppy inserts given puppy in store and returns given id to the puppy Will return an error if value of puppy is negative

func (*SyncStore) DeletePuppy

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

DeletePuppy deletes puppy with given id from store Returns nil if puppy with given id exists. Otherwise returns an error

func (*SyncStore) ReadPuppy

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

ReadPuppy reads puppy with given id from the store Will return an error if puppy with given id does not exist

func (*SyncStore) UpdatePuppy

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

UpdatePuppy update puppy with given id in store if puppy exists Returns nil if puppy with given id exists. Otherwise returns an error

Jump to

Keyboard shortcuts

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