client

package
v0.0.0-...-7bcfc8b Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_HEADER_SIZE = 8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GhostClient

type GhostClient struct {
	MsgHeader []byte
	// contains filtered or unexported fields
}

func New

func New(opt *Options) *GhostClient

func (*GhostClient) CAdd

func (p *GhostClient) CAdd(collectionName string) (string, error)

CADD command. CADD <collection name> Add new collection.

func (*GhostClient) CGet

func (p *GhostClient) CGet(collectionName string) (string, error)

CGET command. CGET <collection name> Change user's collection.

func (*GhostClient) Close

func (c *GhostClient) Close() error

Close the client, releasing any open resources. It is rare to Close a Client, as the Client is meant to be long-lived and shared between many goroutines.

func (*GhostClient) Del

func (p *GhostClient) Del(key string)

DEL command. DEL <key> <val>

func (*GhostClient) Get

func (p *GhostClient) Get(key string) (string, error)

GET command. GET <key>

func (*GhostClient) Ping

func (p *GhostClient) Ping() (*protocol.Reply, error)

PING command.

func (*GhostClient) Process

func (p *GhostClient) Process(cmd *protocol.Command)

func (*GhostClient) Set

func (p *GhostClient) Set(key, val string)

SET command. SET <key> <val>

func (*GhostClient) String

func (c *GhostClient) String() string

type Options

type Options struct {
	// Dialer creates new network connection and has priority
	// over network and Addr options.
	Dialer func() (net.Conn, error)

	// The network type.
	// Default: tcp.
	Network string

	// host:port address.
	Addr string

	// Collection name.
	// Default: "main".
	CollectionName string

	// The maximum number of socket connections.
	// Default: 10 connections.
	PoolSize int

	// Specifies amount of time client waits for connection if all
	// connections are busy before returning an error.
	// Default: 5 seconds.
	PoolTimeout time.Duration

	// Specifies amount of time after which client closes idle connections.
	// Default: not close idle connections.
	IdleTimeout time.Duration

	// Specifies the deadline for establishing new connections.
	// If reached, dial will fail with a timeout.
	DialTiemout time.Duration

	// The maximum number of retries before giving up.
	// Default is to not retry failed commands.
	MaxRetries int
}

func (*Options) GetAddr

func (opt *Options) GetAddr() string

func (*Options) GetCollectionName

func (opt *Options) GetCollectionName() string

func (*Options) GetDialTimeout

func (opt *Options) GetDialTimeout() time.Duration

func (*Options) GetDialer

func (opt *Options) GetDialer() func() (net.Conn, error)

func (*Options) GetIdleTimeout

func (opt *Options) GetIdleTimeout() time.Duration

func (*Options) GetMaxRetries

func (opt *Options) GetMaxRetries() int

func (*Options) GetNetwork

func (opt *Options) GetNetwork() string

func (*Options) GetPoolSize

func (opt *Options) GetPoolSize() int

func (*Options) GetPoolTimeout

func (opt *Options) GetPoolTimeout() time.Duration

Jump to

Keyboard shortcuts

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