store

package
v0.0.0-...-ffe6596 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("Not found")
)

Storage level errors

Functions

This section is empty.

Types

type Memory

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

Memory acts as in-memory paste store

func NewMemory

func NewMemory() *Memory

NewMemory returns a new instance of sore memory implementation

func (*Memory) GetPaste

func (m *Memory) GetPaste(ctx context.Context, id uuid.UUID) (Paste, error)

GetPaste return paste given id

func (*Memory) SavePaste

func (m *Memory) SavePaste(ctx context.Context, p Paste) (Paste, error)

SavePaste stores the paste in memmory

type Paste

type Paste struct {
	Title     string
	ID        uuid.UUID
	Body      string
	Headers   map[string]string
	CreatedAt time.Time
	Expiry    time.Time
}

Paste represents a data to be pasted

type Store

type Store interface {
	SavePaste(context.Context, Paste) (Paste, error)
	GetPaste(ctx context.Context, id uuid.UUID) (Paste, error)
}

Store defines the interface for paste storage

Jump to

Keyboard shortcuts

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