kache

package
v0.0.0-...-e044eaa Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 16 Imported by: 0

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

func (ByteView) Len

func (bv ByteView) Len() int

func (ByteView) String

func (bv ByteView) String() string

type Client

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

func NewClient

func NewClient(service string) *Client

func (*Client) Get

func (c *Client) Get(group string, key string) ([]byte, error)

func (*Client) Watch

func (c *Client) Watch(group string, key string, onUpdated func([]byte))

type Getter

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

type GetterFunc

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

func (GetterFunc) Get

func (f 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)

func (*Group) RegisterPeers

func (g *Group) RegisterPeers(peers PeerPicker)

func (*Group) Set

func (g *Group) Set(key string, value []byte, ttl time.Duration) bool

type PeerGetter

type PeerGetter interface {
	Get(group, key string) ([]byte, error)
	Watch(group, key string, fn func([]byte))
}

type PeerPicker

type PeerPicker interface {
	PickPeer(key string) (peer PeerGetter, ok bool)
	Update(group, key string, value []byte) error
}

type Server

type Server struct {
	pb.UnimplementedKacheServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(self string) *Server

func (*Server) Get

func (s *Server) Get(ctx context.Context, in *pb.Request) (*pb.Response, error)

func (*Server) PickPeer

func (s *Server) PickPeer(key string) (PeerGetter, bool)

func (*Server) SetPeers

func (s *Server) SetPeers(peersAddr ...string)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

func (*Server) Update

func (s *Server) Update(group, key string, value []byte) error

Directories

Path Synopsis
Package cache provides cache strategy support of the kv system, currently we have fifo, lru (default), lfu ...
Package cache provides cache strategy support of the kv system, currently we have fifo, lru (default), lfu ...
package config provides a global Config object
package config provides a global Config object
package consistenthash allows nodes in the cluster to fetch cache from other nodes.
package consistenthash allows nodes in the cluster to fetch cache from other nodes.
package proto stores RPC settings in this project
package proto stores RPC settings in this project
package registry provides service discovery and registration with etcd
package registry provides service discovery and registration with etcd

Jump to

Keyboard shortcuts

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