rest-layer-mem: github.com/rs/rest-layer-mem Index | Files

package mem

import "github.com/rs/rest-layer-mem"

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

Index

Package Files

latency.go mem.go sort.go

type MemoryHandler Uses

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 Uses

func NewHandler() *MemoryHandler

NewHandler creates an empty memory handler

func NewSlowHandler Uses

func NewSlowHandler(latency time.Duration) *MemoryHandler

NewSlowHandler creates an empty memory handler with specified latency

func (*MemoryHandler) Clear Uses

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

Clear clears all items from the memory store matching the lookup

func (*MemoryHandler) Delete Uses

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

Delete deletes an item from memory

func (*MemoryHandler) Find Uses

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

Find items from memory matching the provided lookup

func (*MemoryHandler) Insert Uses

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

Insert inserts new items in memory

func (*MemoryHandler) Update Uses

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

Package mem imports 8 packages (graph) and is imported by 22 packages. Updated 2017-08-07. Refresh now. Tools for package owners.