fuguicache

package module
v0.0.0-...-e0b69c9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 12 Imported by: 0

README

fuguicache

fuguicache is a distributed caching library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteView

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

A ByteView holds an immutable view of bytes.

func (ByteView) ByteSlice

func (v ByteView) ByteSlice() []byte

ByteSlice returns a copy of the data as a byte slice.

func (ByteView) Len

func (v ByteView) Len() int

Len returns the view's length

func (ByteView) String

func (v ByteView) String() string

String returns the data as a string, making a copy if necessary.

type Getter

type Getter interface {
	Get(key string) ([]byte, error)
}

A Getter loads data for a key.

type GetterFunc

type GetterFunc func(key string) ([]byte, error)

A GetterFunc implements Getter with a function.

func (GetterFunc) Get

func (f GetterFunc) Get(key string) ([]byte, error)

Get implements Getter interface function

type Group

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

A Group is a cache namespace and associated data loaded spread over

func GetGroup

func GetGroup(name string) *Group

GetGroup returns the named group previously created with NewGroup, or nil if there's no such group.

func NewGroup

func NewGroup(name string, cacheBytes int64, getter Getter) *Group

NewGroup create a new instance of Group

func (*Group) Get

func (g *Group) Get(key string) (ByteView, error)

Get value for a key from cache

func (*Group) RegisterPeers

func (g *Group) RegisterPeers(peers PeerPicker)

RegisterPeers registers a PeerPicker for choosing remote peer

type HTTPPool

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

HTTPPool implements PeerPicker for a pool of HTTP peers.

func NewHTTPPool

func NewHTTPPool(self string) *HTTPPool

NewHTTPPool initializes an HTTP pool of peers.

func (*HTTPPool) Log

func (p *HTTPPool) Log(format string, v ...interface{})

Log info with server name

func (*HTTPPool) PickPeer

func (p *HTTPPool) PickPeer(key string) (PeerGetter, bool)

PickPeer picks a peer according to key

func (*HTTPPool) ServeHTTP

func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handle all http requests

func (*HTTPPool) Set

func (p *HTTPPool) Set(peers ...string)

type PeerGetter

type PeerGetter interface {
	Get(in *pb.Request, out *pb.Response) error
}

PeerGetter is the interface that must be implemented by a peer.

type PeerPicker

type PeerPicker interface {
	PickPeer(key string) (peer PeerGetter, ok bool)
}

PeerPicker is the interface that must be implemented to locate the peer that owns a specific key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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