ocache

package module
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

删除 main 分支,用 master 分支作为主分支

之前的 commit 脏乱,现在规定一下

  • 开发时,只在 feature 分支上开发
  • 开发完成后,再合并到 master 分支。

v0.7.3

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 (view ByteView) ByteSlice() []byte

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

func (ByteView) Len

func (view ByteView) Len() int

Len returns the view's length

func (ByteView) String

func (view ByteView) String() string

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

type Cache

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

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 HTTPPool

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

HTTPPool implements PeerPicker for a pool of HTTP peers.

func NewHTTPPool

func NewHTTPPool(host 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, request *http.Request)

ServeHTTP handle all http requests.

func (*HTTPPool) Set

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

Set updates the pool's list of peers.

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.

type Relation

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

A Relation is a Cache namespace and associated data loaded spread over.

func GetRelation

func GetRelation(name string) *Relation

GetRelation returns the named class previously created with NewRelation, or nil if there's no such class.

func NewRelation

func NewRelation(name string, cacheBytes int64, getter Getter) *Relation

NewRelation create a new instance of Relation.

func (*Relation) Get

func (r *Relation) Get(key string) (ByteView, error)

Get bytes for a key from Cache.

func (*Relation) RegisterPeers

func (r *Relation) RegisterPeers(peers PeerPicker)

RegisterPeers registers a PeerPicker for choosing remote peer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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