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 will serve as our in-memory DB

func NewMapStore

func NewMapStore() *MapStore

NewMapStore conveniently creates a new initialised syncstore

func (*MapStore) CreatePuppy

func (ms *MapStore) CreatePuppy(pup *puppy.Puppy) (int, error)

CreatePuppy lets you create a new unique puppy in MapStore

func (*MapStore) DeletePuppy

func (ms *MapStore) DeletePuppy(id int) error

DeletePuppy lets you delete a specific puppy in MapStore

func (*MapStore) ReadPuppy

func (ms *MapStore) ReadPuppy(id int) (*puppy.Puppy, error)

ReadPuppy lets you GET a puppy from MapStore if it exists. Else it will return an error

func (*MapStore) UpdatePuppy

func (ms *MapStore) UpdatePuppy(id int, pup *puppy.Puppy) error

UpdatePuppy lets you update a "row" in MapStore

type SyncStore

type SyncStore struct {
	sync.Map

	sync.Mutex
	// contains filtered or unexported fields
}

SyncStore struct. To serve as alternative in-memory DB. It also implements Storer interface

func NewSyncStore

func NewSyncStore() *SyncStore

NewSyncStore conveniently creates a new initialised syncstore

func (*SyncStore) CreatePuppy

func (m *SyncStore) CreatePuppy(pup *puppy.Puppy) (int, error)

CreatePuppy creates a puppy in sync store. Note we use a pointer receiver for this

func (*SyncStore) DeletePuppy

func (m *SyncStore) DeletePuppy(id int) error

DeletePuppy deletes a puppy in sync store

func (*SyncStore) ReadPuppy

func (m *SyncStore) ReadPuppy(id int) (*puppy.Puppy, error)

ReadPuppy retrieves puppy from sync store

func (*SyncStore) UpdatePuppy

func (m *SyncStore) UpdatePuppy(id int, pup *puppy.Puppy) error

UpdatePuppy updates a puppy in sync store

Jump to

Keyboard shortcuts

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