Documentation ¶
Overview ¶
Package epcache implements a distributed cache system.
Index ¶
- type ByteView
- type CacheStats
- type CacheType
- type Getter
- type GetterFunc
- type GrpcPool
- type GrpcPoolOptions
- type LimitMode
- type LoadError
- type NoPeer
- type Node
- func (n *Node) CacheStats(ctype CacheType) CacheStats
- func (n *Node) Get(ctx context.Context, key string) (ByteView, error)
- func (n *Node) OnRemove(key string)
- func (n *Node) OnUpdate(key string, value []byte)
- func (n *Node) RegisterPeers(peers PeerAgent)
- func (n *Node) ResetLimiter()
- func (n *Node) SetFilter(size uint32)
- func (n *Node) SetLimiter(rate float64, cap int64, mode LimitMode)
- type PeerAgent
- type ProtoPeer
- type Stats
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 holds an immutable view of bytes, it should be used as a value type, not a pointer type.
func (ByteView) EqualBytes ¶
EqualBytes returns whether the bytes in bv are the same as the bytes b2.
type CacheStats ¶
type Getter ¶
type Getter interface { // Get depends on users' concrete implementation. // Context's deadline should be treated properly if existed. Get(ctx context.Context, key string) ([]byte, error) }
Getter loads data from source, like a DB.
type GetterFunc ¶
GetterFunc indicates Getter might just be a func.
type GrpcPool ¶
type GrpcPool struct { pb.UnimplementedEPCacheServer // contains filtered or unexported fields }
func NewGrpcPool ¶
func NewGrpcPool(self, prefix string, registry []string, opts *GrpcPoolOptions) *GrpcPool
NewGrpcPool returns a GrpcPool instance.
prefix: The working directory of the EPCache cluster. registry: The listening addresses of the etcd cluster.
type GrpcPoolOptions ¶
type GrpcPoolOptions struct { Replicas int HashFn consistenthash.Hash }
type LoadError ¶
type LoadError string
const ErrNotFound LoadError = "key not found in data source"
ErrNotFound must be returned when Getter can't found the data.
type NoPeer ¶
type NoPeer struct{}
NoPeer is an implementation of PeerAgent, used for groups running in standalone mode.
type Node ¶ added in v1.10.0
type Node struct { Stats Stats // contains filtered or unexported fields }
Node is a set of associated data spreading over one or more processes.
func (*Node) CacheStats ¶ added in v1.10.0
func (n *Node) CacheStats(ctype CacheType) CacheStats
func (*Node) OnRemove ¶ added in v1.10.0
OnRemove removes data in cache and then syncs to all peers in background. This must be called when data in source is purged.
func (*Node) OnUpdate ¶ added in v1.10.0
OnUpdate updates data in cache and then syncs to all peers in background. This must be called when data in source is changed.
func (*Node) RegisterPeers ¶ added in v1.10.0
RegisterPeers specifies PeerPicker for a group, e.n. NoPeer, GrpcPool or any that implements the PeerPicker.
func (*Node) ResetLimiter ¶ added in v1.10.0
func (n *Node) ResetLimiter()
ResetLimiter disables a rate limiter.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package bloomfilter avoids cache penetration.
|
Package bloomfilter avoids cache penetration. |
Package consistenthash implements a ring hash.
|
Package consistenthash implements a ring hash. |
Package lru implements a lru cache.
|
Package lru implements a lru cache. |
Package msgctl reduces messages within a specified interval into one.
|
Package msgctl reduces messages within a specified interval into one. |
Package singleflight provides a duplicate func call suppression mechanism, therefore avoiding cache breakdown.
|
Package singleflight provides a duplicate func call suppression mechanism, therefore avoiding cache breakdown. |