mem

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mem is an example REST backend storage that stores everything in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryHandler

type MemoryHandler struct {
	sync.RWMutex

	// If Latency is set, the handler will introduce an artificial latency on
	// all operations.
	Latency time.Duration
	// contains filtered or unexported fields
}

MemoryHandler is an example handler storing data in memory.

func NewHandler

func NewHandler() *MemoryHandler

NewHandler creates an empty memory handler.

func NewSlowHandler

func NewSlowHandler(latency time.Duration) *MemoryHandler

NewSlowHandler creates an empty memory handler with specified latency.

func (*MemoryHandler) Clear

func (m *MemoryHandler) Clear(ctx context.Context, q *query.Query) (total int, err error)

Clear clears all items from the memory store matching q.

func (*MemoryHandler) Delete

func (m *MemoryHandler) Delete(ctx context.Context, item *resource.Item) (err error)

Delete deletes an item from memory.

func (*MemoryHandler) Find

func (m *MemoryHandler) Find(ctx context.Context, q *query.Query) (list *resource.ItemList, err error)

Find items from memory matching the q.

func (*MemoryHandler) Insert

func (m *MemoryHandler) Insert(ctx context.Context, items []*resource.Item) (err error)

Insert inserts new items in memory.

func (*MemoryHandler) Update

func (m *MemoryHandler) Update(ctx context.Context, item *resource.Item, original *resource.Item) (err error)

Update replace an item by a new one in memory.

Jump to

Keyboard shortcuts

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