client

package
v0.0.0-...-80f65e5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client that communicates with a server.

func New

func New(addr string, addrs ...string) (*Client, error)

New creates a new client with the given servet addresses.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) Del

func (c *Client) Del(key string) StatusResult

Del deletes the given key.

func (*Client) DelWithContext

func (c *Client) DelWithContext(ctx context.Context, key string) StatusResult

DelWithContext similar to Del but with context.

func (*Client) Expire

func (c *Client) Expire(key string, secs int) StatusResult

Expire sets expiration of the given key as `now + secs`.

func (*Client) ExpireWithContext

func (c *Client) ExpireWithContext(ctx context.Context, key string, secs int) StatusResult

ExpireWithContext similar to Expire but with context.

func (*Client) Get

func (c *Client) Get(key string) ScalarResult

Get gets a value at the given key.

func (*Client) GetBit

func (c *Client) GetBit(key string, offset uint64) ScalarResult

GetBit returns the bit value at the offset in the string stored at key.

func (*Client) GetBitWithContext

func (c *Client) GetBitWithContext(ctx context.Context, key string, offset uint64) ScalarResult

GetBitWithContext similar to GetBit but with context.

func (*Client) GetWithContext

func (c *Client) GetWithContext(ctx context.Context, key string) ScalarResult

GetWithContext similar to Get but with the context.

func (*Client) HDel

func (c *Client) HDel(key string, field string, fields ...string) ScalarResult

HDel deletes given fields from map stored at the given key.

func (*Client) HDelWithContext

func (c *Client) HDelWithContext(ctx context.Context, key, field string, fields ...string) ScalarResult

HDelWithContext similar to HDel but with context.

func (*Client) HGet

func (c *Client) HGet(key, field string) ScalarResult

HGet returns the value associated with field in the hash stored at key.

func (*Client) HGetWithContext

func (c *Client) HGetWithContext(ctx context.Context, key, field string) ScalarResult

HGetWithContext similar to HGet but with context.

func (*Client) HKeys

func (c *Client) HKeys(key string) ListResult

HKeys returns all keys of the map stored at the given key.

func (*Client) HKeysWithContext

func (c *Client) HKeysWithContext(ctx context.Context, key string) ListResult

HKeysWithContext similar to Hkeys by with context.

func (*Client) HSet

func (c *Client) HSet(key, field, value string) StatusResult

HSet sets a field in hash at the given key.

func (*Client) HSetWithContext

func (c *Client) HSetWithContext(ctx context.Context, key, field, value string) StatusResult

HSetWithContext similar to HSet but with context.

func (*Client) HVals

func (c *Client) HVals(key string) ListResult

HVals returns values of a hash stored at the given key.

func (*Client) HValsWithContext

func (c *Client) HValsWithContext(ctx context.Context, key string) ListResult

HValsWithContext similar to HVals but with context.

func (*Client) Keys

func (c *Client) Keys(pattern string) ListResult

Keys returns all keys that matched to the given pattern.

func (*Client) KeysWithContext

func (c *Client) KeysWithContext(ctx context.Context, pattern string) ListResult

KeysWithContext similar to Keys but with context.

func (*Client) LIndex

func (c *Client) LIndex(key string, index int) ScalarResult

LIndex returns a value at the index in the list stored at the given key.

func (*Client) LIndexWithContext

func (c *Client) LIndexWithContext(ctx context.Context, key string, index int) ScalarResult

LIndexWithContext similar to LIndex but with context.

func (*Client) LLen

func (c *Client) LLen(key string) ScalarResult

LLen returns a number of the elements in the list stored at the given key.

func (*Client) LLenWithContext

func (c *Client) LLenWithContext(ctx context.Context, key string) ScalarResult

LLenWithContext similar to LLen but with context.

func (*Client) LPop

func (c *Client) LPop(key string) ScalarResult

LPop removes and returns the first element of the list stored at the given key.

func (*Client) LPopWithContext

func (c *Client) LPopWithContext(ctx context.Context, key string) ScalarResult

LPopWithContext similar to LPop but with context.

func (*Client) LPush

func (c *Client) LPush(key, value string) StatusResult

LPush prepends a new value to the list stored at the given key.

func (*Client) LPushWithContext

func (c *Client) LPushWithContext(ctx context.Context, key, value string) StatusResult

LPushWithContext similar to LPush but with context.

func (*Client) LRange

func (c *Client) LRange(key string, start, stop int) ListResult

LRange returns elements from the list stored at the given key. Start and stop are zero-based indexes.

func (*Client) LRangeWithContext

func (c *Client) LRangeWithContext(ctx context.Context, key string, start, stop int) ListResult

LRangeWithContext similar to LRange but with context.

func (*Client) LRem

func (c *Client) LRem(key, value string) StatusResult

LRem removes a given value from the list stored at the given key.

func (*Client) LRemWithContext

func (c *Client) LRemWithContext(ctx context.Context, key, value string) StatusResult

LRemWithContext similar to LRem but with context.

func (*Client) Ping

func (c *Client) Ping(args ...string) ScalarResult

Ping returns PONG if no argument is provided, otherwise returns a copy of the argument as a bulk.

func (*Client) PingWithContext

func (c *Client) PingWithContext(ctx context.Context, args ...string) ScalarResult

PingWithContext similar to Ping but with context.

func (*Client) RPop

func (c *Client) RPop(key string) ScalarResult

RPop removes and returns the last element of the list stored at the given key.

func (*Client) RPopWithContext

func (c *Client) RPopWithContext(ctx context.Context, key string) ScalarResult

RPopWithContext similar to RPop but with context.

func (*Client) RPush

func (c *Client) RPush(key, value string, values ...string) StatusResult

RPush appends a new value(s) to the list stored at the given key.

func (*Client) RPushWithContext

func (c *Client) RPushWithContext(ctx context.Context, key, value string, values ...string) StatusResult

RPushWithContext similar to RPush but with context.

func (*Client) Set

func (c *Client) Set(key, value string) StatusResult

Set sets a new value at the given key.

func (*Client) SetBit

func (c *Client) SetBit(key string, offset, value uint64) StatusResult

SetBit sets or clears the bit at offset in the bitmap stored at key.

func (*Client) SetBitWithContext

func (c *Client) SetBitWithContext(ctx context.Context, key string, offset, value uint64) StatusResult

SetBitWithContext similar to SetBit but with context.

func (*Client) SetWithContext

func (c *Client) SetWithContext(ctx context.Context, key, value string) StatusResult

SetWithContext similar to Set but with the context.

func (*Client) Strlen

func (c *Client) Strlen(key string) ScalarResult

Strlen returns a length of the string stored at key.

func (*Client) StrlenWithContext

func (c *Client) StrlenWithContext(ctx context.Context, key string) ScalarResult

StrlenWithContext similar to Strlen but with context.

func (*Client) TTL

func (c *Client) TTL(key string) ScalarResult

TTL returns the remaining time to live of a key. -1 returns if key does not have timeout.

func (*Client) TTLWithContext

func (c *Client) TTLWithContext(ctx context.Context, key string) ScalarResult

TTLWithContext similar to TTL but with context.

func (*Client) Type

func (c *Client) Type(key string) ScalarResult

Type returns a data type of a value stored at key.

func (*Client) TypeWithContext

func (c *Client) TypeWithContext(ctx context.Context, key string) ScalarResult

TypeWithContext similar to Type but with context.

type ListResult

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

ListResult is used when command respond with slice.

func (ListResult) Err

func (lr ListResult) Err() error

Err returns an error.

func (ListResult) IsNil

func (lr ListResult) IsNil() bool

IsNil returns true if the underlaying value and error is empty.

func (ListResult) Val

func (lr ListResult) Val() ([]string, error)

Val returns the underlying slice if no error. Otherwise, the error will be returned.

type ScalarResult

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

ScalarResult is a scalar result like string, int, etc.

func (ScalarResult) Err

func (sr ScalarResult) Err() error

Err returns an error.

func (ScalarResult) Int64

func (sr ScalarResult) Int64() (int64, error)

Int64 converts scalar value to the int64.

func (ScalarResult) IsNil

func (sr ScalarResult) IsNil() bool

IsNil returns true if the underlying value and error is empty.

func (ScalarResult) Val

func (sr ScalarResult) Val() (string, error)

Val returns a string representation.

type StatusResult

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

StatusResult is used when a command can respond only with success or with error.

func (StatusResult) Err

func (sr StatusResult) Err() error

Err returns an error.

Jump to

Keyboard shortcuts

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