inmemory

package
v0.0.0-...-72b452d Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

Storage is an in-memory storage system that uses a map to store Payment structs indexed by UUID.

func (*Storage) Create

func (s *Storage) Create(p storage.Payment) (uuid.UUID, error)

Create will add the given Payment to the store, and return its UUID.

func (*Storage) CreateSpecificID

func (s *Storage) CreateSpecificID(id uuid.UUID, p storage.Payment) error

CreateSpecificID will create the given Payment with that specific UUID, rather than generating its own. Intended for use with testing, and not in production.

func (*Storage) Delete

func (s *Storage) Delete(id uuid.UUID) error

Delete will remove the Payment at the given UUID from the internal store.

func (*Storage) Initialise

func (s *Storage) Initialise() error

Initialise will initialise the internal map.

func (*Storage) Read

func (s *Storage) Read(id uuid.UUID) (storage.Payment, error)

Read will attempt to find the Payment linked to the given UUID.

func (*Storage) ReadAll

func (s *Storage) ReadAll(rao storage.ReadAllOptions) (map[uuid.UUID]storage.Payment, error)

ReadAll will read all available Payments, up to the limit which is either 1) explicit in the given ReadAllOptions struct, or 2) the default limit which is also exported by this package. The Payments will be returned in order based on their respective UUIDs. The entire collection of Payments can be paginated through via the Offset property of the ReadAllOptions struct, and by default when such an Offset is not explicitly specified, the returned collection will start from the beginning of the store.

func (*Storage) Terminate

func (s *Storage) Terminate(...bool) error

Terminate will terminate the internal map by setting the internal store to nil, so that the garbage collector will pick up the map's contents. It does not bother checking the true/false argument for whether or not to destroy the stored data, due to the very nature of its implementation.

func (*Storage) Update

func (s *Storage) Update(id uuid.UUID, p storage.Payment) error

Update will overwrite the Payment currently stored at the given UUID with the given Payment.

Jump to

Keyboard shortcuts

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