client

package
v0.0.0-...-526e3f3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 17 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableAutoReconnect

func EnableAutoReconnect(opt *ServerOption)

func EnableHeartbeat

func EnableHeartbeat(opt *ServerOption)

Types

type Item

type Item struct {
	Key        string
	Value      []byte
	Flags      []byte
	Expiration int
	Cas        uint64

	Server string
}

type Node

type Node struct {
	Server Server
	// contains filtered or unexported fields
}

type Ring

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

func NewRing

func NewRing(servers ...Server) *Ring

func (*Ring) Close

func (r *Ring) Close() error

func (*Ring) Each

func (r *Ring) Each(fn func(s Server) error) error

func (*Ring) Find

func (r *Ring) Find(name string) Server

func (*Ring) Pick

func (r *Ring) Pick(key string) Server

type Server

type Server interface {
	Name() string
	Close() error
	Get(key string) (*Item, error)
	GetMulti(keys ...string) ([]*Item, error)
	Set(item *Item) error
	Add(item *Item) error
	Replace(item *Item) error
	Delete(key string) error
	Increment(key string, delta int, expiration int) (int64, error)
	Decrement(key string, delta int, expiration int) (int64, error)
	Touch(key string, expiration int) error
	Flush() error
	Version() (string, error)
	Reconnect() error
}

type ServerOperationType

type ServerOperationType string
const (
	ServerDeleteOnly ServerOperationType = "delete_only"
	ServerWriteOnly  ServerOperationType = "write_only"
)

type ServerOpt

type ServerOpt func(*ServerOption)

type ServerOption

type ServerOption struct {
	HeartbeatInterval   time.Duration
	EnableAutoReconnect bool
}

type ServerWithBinaryProtocol

type ServerWithBinaryProtocol struct {
	Network string
	Addr    string
	Type    ServerOperationType
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewServerWithBinaryProtocol

func NewServerWithBinaryProtocol(ctx context.Context, name, network, addr string, opts ...ServerOpt) (*ServerWithBinaryProtocol, error)

func (*ServerWithBinaryProtocol) Add

func (s *ServerWithBinaryProtocol) Add(item *Item) error

func (*ServerWithBinaryProtocol) Close

func (s *ServerWithBinaryProtocol) Close() error

func (*ServerWithBinaryProtocol) Decrement

func (s *ServerWithBinaryProtocol) Decrement(key string, delta, expiration int) (int64, error)

func (*ServerWithBinaryProtocol) Delete

func (s *ServerWithBinaryProtocol) Delete(key string) error

func (*ServerWithBinaryProtocol) Flush

func (s *ServerWithBinaryProtocol) Flush() error

func (*ServerWithBinaryProtocol) Get

func (s *ServerWithBinaryProtocol) Get(key string) (*Item, error)

func (*ServerWithBinaryProtocol) GetMulti

func (s *ServerWithBinaryProtocol) GetMulti(keys ...string) ([]*Item, error)

func (*ServerWithBinaryProtocol) Increment

func (s *ServerWithBinaryProtocol) Increment(key string, delta, expiration int) (int64, error)

func (*ServerWithBinaryProtocol) Name

func (s *ServerWithBinaryProtocol) Name() string

func (*ServerWithBinaryProtocol) Reconnect

func (s *ServerWithBinaryProtocol) Reconnect() error

func (*ServerWithBinaryProtocol) Replace

func (s *ServerWithBinaryProtocol) Replace(item *Item) error

func (*ServerWithBinaryProtocol) Set

func (s *ServerWithBinaryProtocol) Set(item *Item) error

func (*ServerWithBinaryProtocol) Touch

func (s *ServerWithBinaryProtocol) Touch(key string, expiration int) error

func (*ServerWithBinaryProtocol) Version

func (s *ServerWithBinaryProtocol) Version() (string, error)

type ServerWithMetaProtocol

type ServerWithMetaProtocol struct {
	Network string
	Addr    string
	Type    ServerOperationType
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewServerWithMetaProtocol

func NewServerWithMetaProtocol(ctx context.Context, name, network, addr string, opts ...ServerOpt) (*ServerWithMetaProtocol, error)

func (*ServerWithMetaProtocol) Add

func (s *ServerWithMetaProtocol) Add(item *Item) error

func (*ServerWithMetaProtocol) Close

func (s *ServerWithMetaProtocol) Close() error

func (*ServerWithMetaProtocol) Decrement

func (s *ServerWithMetaProtocol) Decrement(key string, delta, _ int) (int64, error)

Decrement is decrement value when if exist key. implement is same as textProtocol.Decr.

func (*ServerWithMetaProtocol) Delete

func (s *ServerWithMetaProtocol) Delete(key string) error

func (*ServerWithMetaProtocol) Flush

func (s *ServerWithMetaProtocol) Flush() error

func (*ServerWithMetaProtocol) Get

func (s *ServerWithMetaProtocol) Get(key string) (*Item, error)

func (*ServerWithMetaProtocol) GetMulti

func (s *ServerWithMetaProtocol) GetMulti(keys ...string) ([]*Item, error)

func (*ServerWithMetaProtocol) Increment

func (s *ServerWithMetaProtocol) Increment(key string, delta, _ int) (int64, error)

Increment is increment value when if exist key. implement is same as textProtocol.Incr.

func (*ServerWithMetaProtocol) Name

func (s *ServerWithMetaProtocol) Name() string

func (*ServerWithMetaProtocol) Reconnect

func (s *ServerWithMetaProtocol) Reconnect() error

func (*ServerWithMetaProtocol) Replace

func (s *ServerWithMetaProtocol) Replace(item *Item) error

func (*ServerWithMetaProtocol) Set

func (s *ServerWithMetaProtocol) Set(item *Item) error

func (*ServerWithMetaProtocol) Touch

func (s *ServerWithMetaProtocol) Touch(key string, expiration int) error

func (*ServerWithMetaProtocol) Version

func (s *ServerWithMetaProtocol) Version() (string, error)

type ServerWithTextProtocol

type ServerWithTextProtocol struct {
	Network string
	Addr    string
	Type    ServerOperationType
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewServerWithTextProtocol

func NewServerWithTextProtocol(ctx context.Context, name, network, addr string, opts ...ServerOpt) (*ServerWithTextProtocol, error)

func (*ServerWithTextProtocol) Add

func (s *ServerWithTextProtocol) Add(item *Item) error

func (*ServerWithTextProtocol) Close

func (s *ServerWithTextProtocol) Close() error

func (*ServerWithTextProtocol) Decrement

func (s *ServerWithTextProtocol) Decrement(key string, delta, _ int) (int64, error)

func (*ServerWithTextProtocol) Delete

func (s *ServerWithTextProtocol) Delete(key string) error

func (*ServerWithTextProtocol) Flush

func (s *ServerWithTextProtocol) Flush() error

func (*ServerWithTextProtocol) Get

func (s *ServerWithTextProtocol) Get(key string) (*Item, error)

func (*ServerWithTextProtocol) GetMulti

func (s *ServerWithTextProtocol) GetMulti(keys ...string) ([]*Item, error)

func (*ServerWithTextProtocol) Increment

func (s *ServerWithTextProtocol) Increment(key string, delta, _ int) (int64, error)

func (*ServerWithTextProtocol) Name

func (s *ServerWithTextProtocol) Name() string

func (*ServerWithTextProtocol) Reconnect

func (s *ServerWithTextProtocol) Reconnect() error

func (*ServerWithTextProtocol) Replace

func (s *ServerWithTextProtocol) Replace(item *Item) error

func (*ServerWithTextProtocol) Set

func (s *ServerWithTextProtocol) Set(item *Item) error

func (*ServerWithTextProtocol) Touch

func (s *ServerWithTextProtocol) Touch(key string, expiration int) error

func (*ServerWithTextProtocol) Version

func (s *ServerWithTextProtocol) Version() (string, error)

type SinglePool

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

func NewSinglePool

func NewSinglePool(servers ...Server) (*SinglePool, error)

func (*SinglePool) Add

func (c *SinglePool) Add(item *Item) error

func (*SinglePool) Close

func (c *SinglePool) Close() error

func (*SinglePool) Decrement

func (c *SinglePool) Decrement(key string, delta, expiration int) (int64, error)

func (*SinglePool) Delete

func (c *SinglePool) Delete(key string) error

func (*SinglePool) Flush

func (c *SinglePool) Flush() error

func (*SinglePool) Get

func (c *SinglePool) Get(key string) (*Item, error)

func (*SinglePool) GetMulti

func (c *SinglePool) GetMulti(keys ...string) ([]*Item, error)

func (*SinglePool) Increment

func (c *SinglePool) Increment(key string, delta, expiration int) (int64, error)

func (*SinglePool) Replace

func (c *SinglePool) Replace(item *Item) error

func (*SinglePool) Set

func (c *SinglePool) Set(item *Item) error

func (*SinglePool) Touch

func (c *SinglePool) Touch(key string, expiration int) error

func (*SinglePool) Version

func (c *SinglePool) Version() (map[string]string, error)

Jump to

Keyboard shortcuts

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