distributed

package module
v0.0.0-...-96bd095 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

分布式缓存

1. LRU缓存

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Getter

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

Getter 加载key的数据

type GetterFunc

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

GetterFunc 通过函数实现Getter

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
}

Loader 一个缓存名称空间,相关的数据加载分布

func GetGroup

func GetGroup(name string) *Group

func NewGroup

func NewGroup(name string, mainCache *SyncCache, getter Getter) *Group

func NewGroupDefault

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

NewGroup create a new instance of Loader

func (*Group) Get

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

Get 通过key获取value

func (*Group) RegisterPeers

func (g *Group) RegisterPeers(peers remote.PeerPicker)

type ReadBytes

type ReadBytes []byte

func (ReadBytes) ByteSlice

func (v ReadBytes) ByteSlice() []byte

func (ReadBytes) Len

func (v ReadBytes) Len() int

func (ReadBytes) String

func (v ReadBytes) String() string

type SyncCache

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

func NewSyncCache

func NewSyncCache(c cache.Cache) *SyncCache

func NewSyncCacheDefault

func NewSyncCacheDefault(cacheBytes int64) *SyncCache

func (*SyncCache) Add

func (s *SyncCache) Add(key string, value cache.Value)

func (*SyncCache) Get

func (s *SyncCache) Get(key string) (value ReadBytes, ok bool)

Directories

Path Synopsis
lru

Jump to

Keyboard shortcuts

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