tinyGoCache

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

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

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
}

func (ByteView) ByteSlice

func (v ByteView) ByteSlice() []byte

func (ByteView) Len

func (v ByteView) Len() int

func (ByteView) String

func (v ByteView) String() string

type Getter

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

type GetterFunc

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

实现Getter接口

func (GetterFunc) Get

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

定义一个函数类型 F,并且实现接口 A 的方法,然后在这个方法中调用自己。 这是 Go 语言中将其他函数(参数返回值定义与 F 一致)转换为接口 A 的常用技巧。

type Group

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

核心数据结构

func GetGroup

func GetGroup(name string) *Group

func NewGroup

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

func (*Group) Get

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

func (*Group) RegisterPeers

func (g *Group) RegisterPeers(peers PeerPicker)

注册节点选择器

type HTTPPool

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

func NewHTTPPool

func NewHTTPPool(self string) *HTTPPool

func (*HTTPPool) Log

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

func (*HTTPPool) PickPeer

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

func (*HTTPPool) ServeHTTP

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

func (*HTTPPool) Set

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

实现PeerPicker接口

type PeerGetter

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

type PeerPicker

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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