Documentation ¶
Index ¶
- Constants
- type Config
- type Memcache
- type MemcacheOption
- type Pipeline
- func (p *Pipeline) Delete(key string, options memproxy.DeleteOptions) func() (memproxy.DeleteResponse, error)
- func (p *Pipeline) Execute()
- func (p *Pipeline) Finish()
- func (p *Pipeline) LeaseGet(key string, options memproxy.LeaseGetOptions) memproxy.LeaseGetResult
- func (p *Pipeline) LeaseSet(key string, data []byte, cas uint64, options memproxy.LeaseSetOptions) func() (memproxy.LeaseSetResponse, error)
- func (p *Pipeline) LowerSession() memproxy.Session
- type ReplicatedRouteOption
- type Route
- type Selector
- type ServerConfig
- type ServerID
- type ServerStats
- type SimpleServerConfig
- type SimpleServerStats
- type SimpleStatsOption
- type StatsClient
Constants ¶
const RandomMaxValues uint64 = 1000000
RandomMaxValues random from 0 => 999,999
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Memcache ¶
type Memcache struct {
// contains filtered or unexported fields
}
Memcache is thread safe
func New ¶
func New[S ServerConfig]( conf Config[S], newFunc func(conf S) memproxy.Memcache, options ...MemcacheOption, ) (*Memcache, error)
New ...
func NewSimpleReplicatedMemcache ¶
func NewSimpleReplicatedMemcache( servers []SimpleServerConfig, numConnsPerServer int, stats ServerStats, options ...ReplicatedRouteOption, ) (*Memcache, func(), error)
NewSimpleReplicatedMemcache ...
type MemcacheOption ¶
type MemcacheOption func(conf *memcacheConfig)
MemcacheOption ...
func WithMemcacheSessionProvider ¶
func WithMemcacheSessionProvider(provider memproxy.SessionProvider) MemcacheOption
WithMemcacheSessionProvider ...
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline is NOT thread safe
func (*Pipeline) Delete ¶
func (p *Pipeline) Delete( key string, options memproxy.DeleteOptions, ) func() (memproxy.DeleteResponse, error)
Delete ...
func (*Pipeline) LeaseGet ¶
func (p *Pipeline) LeaseGet( key string, options memproxy.LeaseGetOptions, ) memproxy.LeaseGetResult
LeaseGet ...
func (*Pipeline) LeaseSet ¶
func (p *Pipeline) LeaseSet( key string, data []byte, cas uint64, options memproxy.LeaseSetOptions, ) func() (memproxy.LeaseSetResponse, error)
LeaseSet ...
func (*Pipeline) LowerSession ¶
LowerSession returns a lower priority session
type ReplicatedRouteOption ¶
type ReplicatedRouteOption func(conf *replicatedRouteConfig)
ReplicatedRouteOption ...
func WithMemoryScoringFunc ¶ added in v0.5.0
func WithMemoryScoringFunc(memScoreFunc func(mem float64) float64) ReplicatedRouteOption
WithMemoryScoringFunc changes the weight function for replication load-balancing
func WithMinPercentage ¶
func WithMinPercentage(percentage float64) ReplicatedRouteOption
WithMinPercentage minimum request percentage to memcached servers
func WithRandFunc ¶
func WithRandFunc(randFunc func(n uint64) uint64) ReplicatedRouteOption
WithRandFunc ...
type Route ¶
type Route interface { // NewSelector ... NewSelector() Selector // AllServerIDs returns list of all possible server ids AllServerIDs() []ServerID }
Route must be Thread Safe
func NewReplicatedRoute ¶
func NewReplicatedRoute( servers []ServerID, stats ServerStats, options ...ReplicatedRouteOption, ) Route
NewReplicatedRoute ...
type Selector ¶
type Selector interface { // SetFailedServer ... SetFailedServer(server ServerID) // HasNextAvailableServer check if next available server ready to be fallback to HasNextAvailableServer() bool // SelectServer choose a server id, will keep in this server id unless Reset is call or failed server added SelectServer(key string) ServerID // SelectForDelete choose servers for deleting SelectForDelete(key string) []ServerID // Reset the selection Reset() }
Selector is NOT thread safe
type ServerConfig ¶
type ServerConfig interface { // GetID returns the server id, must be unique GetID() ServerID }
ServerConfig is a constraint for server config type
type ServerStats ¶
type ServerStats interface { // IsServerFailed check whether the server is currently not connected IsServerFailed(server ServerID) bool // NotifyServerFailed ... NotifyServerFailed(server ServerID) // GetMemUsage returns memory usage in bytes GetMemUsage(server ServerID) float64 }
ServerStats is thread safe
type SimpleServerConfig ¶
SimpleServerConfig ...
type SimpleServerStats ¶
type SimpleServerStats struct {
// contains filtered or unexported fields
}
SimpleServerStats ...
func NewSimpleServerStats ¶
func NewSimpleServerStats[S ServerConfig]( servers []S, factory func(conf S) StatsClient, options ...SimpleStatsOption, ) *SimpleServerStats
NewSimpleServerStats ...
func NewSimpleStats ¶
func NewSimpleStats(servers []SimpleServerConfig, options ...SimpleStatsOption) *SimpleServerStats
NewSimpleStats ...
func (*SimpleServerStats) GetMemUsage ¶
func (s *SimpleServerStats) GetMemUsage(server ServerID) float64
GetMemUsage returns memory usage in bytes
func (*SimpleServerStats) IsServerFailed ¶
func (s *SimpleServerStats) IsServerFailed(server ServerID) bool
IsServerFailed check whether the server is currently not connected
func (*SimpleServerStats) NotifyServerFailed ¶
func (s *SimpleServerStats) NotifyServerFailed(server ServerID)
NotifyServerFailed ...
type SimpleStatsOption ¶
type SimpleStatsOption func(conf *simpleStatsConfig)
SimpleStatsOption ...
func WithSimpleStatsCheckDuration ¶
func WithSimpleStatsCheckDuration(d time.Duration) SimpleStatsOption
WithSimpleStatsCheckDuration ...
func WithSimpleStatsErrorLogger ¶
func WithSimpleStatsErrorLogger(logger func(err error)) SimpleStatsOption
WithSimpleStatsErrorLogger ...
func WithSimpleStatsMemLogger ¶
func WithSimpleStatsMemLogger(memLogger func(server ServerID, mem uint64, err error)) SimpleStatsOption
WithSimpleStatsMemLogger ...
type StatsClient ¶
type StatsClient interface { // GetMemUsage get memory usage in bytes GetMemUsage() (uint64, error) // Close client Close() error }
StatsClient ...
func NewSimpleStatsClient ¶
func NewSimpleStatsClient(conf SimpleServerConfig) StatsClient
NewSimpleStatsClient ...