gdcache

package module
v0.0.0-...-8eff6b3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 12 Imported by: 0

README

gdcache

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
}

ByteView 一个只读数据结构,用来封装缓存值

func (ByteView) ByteSlice

func (v ByteView) ByteSlice() []byte

ByteSlice method 返回一个拷贝的字节切片

func (ByteView) Len

func (v ByteView) Len() int

Len method 获取缓存值字节长度

func (ByteView) String

func (v ByteView) String() string

type Getter

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

Getter interface 定义获取源数据的回调函数接口

type GetterFunc

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

GetterFunc 实现Getter接口

func (GetterFunc) Get

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

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)

Get method 从缓存中得到数据

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 ...any)

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)

type PeerGetter

type PeerGetter interface {
	// Get(group string, key string) ([]byte, error)
	Get(in *pb.Request, out *pb.Response) error
}

PeerGetter 节点接口

type PeerPicker

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

PeerPicker 节点选择接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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