gee_cache

package module
v0.0.0-...-3a46f29 Latest Latest
Warning

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

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

README

gee-cache

Documentation

Index

Constants

View Source
const BasePath = "/_gee_cache/"

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

ByteSlice 返回一个拷贝值

func (ByteView) Len

func (byteView ByteView) Len() int64

Len 计算对象的字节数

func (ByteView) String

func (byteView ByteView) String() string

String 返回字符串表示

type Cache

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

func NewCache

func NewCache(maxBytes int64) *Cache

func (*Cache) Get

func (cache *Cache) Get(key string) (ByteView, bool)

func (*Cache) Set

func (cache *Cache) Set(key string, value ByteView)

type Getter

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

type GetterFunc

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

func (GetterFunc) Get

func (getFunc 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, maxBytes int64, getter Getter) *Group

func (*Group) Get

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

先从current获取 如果获取失败则调用getter获取 获取到了需要跟更新到current

type HashFunc

type HashFunc func(data []byte) uint32

hash 函数的形式

type HttpPool

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

func NewHttpPool

func NewHttpPool(self string) *HttpPool

func (*HttpPool) ServeHTTP

func (pool *HttpPool) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Map

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

func NewMap

func NewMap(hash HashFunc, replicas int) *Map

func (*Map) Add

func (m *Map) Add(nodes ...string)

Add 添加实际节点

func (*Map) Get

func (m *Map) Get(key string) string

Get 获取key实际应该到哪个节点获取,返回节点名称

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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