repo

package
v0.0.0-...-d49ac33 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("value was not found in repository")

Functions

This section is empty.

Types

type Map

type Map struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

Map is a in-memory keystore which implements the Repository interface which is used for testing

func (Map) Close

func (m Map) Close() error

func (*Map) Get

func (m *Map) Get(ctx context.Context, key string) (string, error)

Get a value out of a map

func (*Map) Set

func (m *Map) Set(ctx context.Context, key, val string) error

Set a value within the map

type Redis

type Redis struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

Redis is a key value store which satisfies the Repository interface

func (*Redis) Close

func (r *Redis) Close() error

Close the connection to the redis instance

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, key string) (val string, err error)

Get a value out of the redis instance given the corresponding key

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, key, val string) (err error)

Set a key and value within the redis instance

type Repository

type Repository interface {
	Set(ctx context.Context, key string, value string) error
	Get(ctx context.Context, key string) (string, error)
	io.Closer
}

Repository is a key value datastore where urls and there corresponding hashs are kept

func NewMap

func NewMap(timeout time.Duration) Repository

NewMap will create a new repository

func NewRedisRepo

func NewRedisRepo(addr, pwd string, timeout time.Duration) (Repository, error)

NewRedisRepo will create a new Repository given the address, password of the redis instance

Jump to

Keyboard shortcuts

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