distcache

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 8 Imported by: 0

README

Distcache

WORK IN PROGRESS

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(opts Options) *Cache

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) ([]byte, ResultSource, error)

func (*Cache) SetPeers

func (c *Cache) SetPeers(peers ...string)

type Getter

type Getter interface {
	Get(ctx context.Context, key string) ([]byte, error)
}

type GetterFunc

type GetterFunc func(ctx context.Context, key string) ([]byte, error)

func (GetterFunc) Get

func (gf GetterFunc) Get(ctx context.Context, key string) ([]byte, error)

type Options

type Options struct {
	Me          string
	HotStore    Store
	LocalStore  Store
	Getter      Getter
	PeerCreator PeerCreator
	Peers       []string
}

type Peer

type Peer interface {
	io.Closer
	Get(ctx context.Context, key string) ([]byte, ResultSource, error)
}

type PeerCreator

type PeerCreator interface {
	NewPeer(addr string) Peer
}

type ResultSource

type ResultSource int
const (
	ResultNone ResultSource = iota
	ResultHotCache
	ResultLocalCache
	ResultLocalGet
	ResultPeerCache
	ResultPeerGet
)

func (ResultSource) String

func (rs ResultSource) String() string

type Setter

type Setter interface {
	Set(ctx context.Context, key string, val []byte) error
}

type Store

type Store interface {
	Getter
	Setter
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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