memory

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

The memory package provides methods to work with pastes using memory as a * storage. * * This package provides a PasteService type that implements api.PasteService * interface and use a map of Pastes as a storage. * * Note: according to the documentation (https://blog.golang.org/maps#TOC_6.), * maps are not safe for concurrent use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PasteService

type PasteService struct {
	Pastes map[uint64]*api.Paste
}

PasteService stores all the pastes in memory and implements the api.PasteService interface.

func New

func New() *PasteService

New returns new PasteService with an empty map of pastes.

func (*PasteService) Create

func (s *PasteService) Create(p *api.Paste) error

Create adds a new paste to the storage

func (*PasteService) Delete

func (s *PasteService) Delete(id uint64) error

Delete removes the paste from the storage

func (*PasteService) Paste

func (s *PasteService) Paste(id uint64) (*api.Paste, error)

Paste returns a paste by it's ID.

Jump to

Keyboard shortcuts

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