client

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKeyPrefix

func GetKeyPrefix(key string) (bkey []byte, rangEnd []byte)

GetKeyPrefix returns the actual rangeStart and rangeEnd for keys that end with '*'.

func GetPermission

func GetPermission(key string, permName string) *pb.Permission

GetPermission returns a new Permission object for the given information or nil if permName unrecognized.

Types

type Client

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

Client object.

func NewClient

func NewClient(config Config) (*Client, error)

NewClient returns a new Client object.

func (*Client) AuthDisable

func (c *Client) AuthDisable() error

AuthDisable disables authentication.

func (*Client) AuthEnable

func (c *Client) AuthEnable() error

AuthEnable enables authentication.

func (*Client) Authenticate

func (c *Client) Authenticate(username, password string) (string, error)

Authenticate processes an authenticate request.

func (*Client) Clear

func (c *Client) Clear() error

Clear the cache.

func (*Client) Close

func (c *Client) Close()

Close the connection to the server.

func (*Client) CloseEventChannel

func (c *Client) CloseEventChannel(id int64)

CloseEventChannel closes the Event channel.

func (*Client) DecrementFloat

func (c *Client) DecrementFloat(key string, by float64) (float64, error)

DecrementFloat decrements a float stored at the given key by the given number and returns new value.

func (*Client) DecrementInt

func (c *Client) DecrementInt(key string, by int64) (int64, error)

DecrementInt decrements an integer stored at the given key by the given number and returns new value.

func (*Client) DelHashField

func (c *Client) DelHashField(key, field string) error

DelHashField deletes a field from a hash.

func (*Client) Delete

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

Delete removes a key from the cache.

func (*Client) Get

func (c *Client) Get(key string) util.Value

Get a value from the cache.

func (*Client) GetHashField

func (c *Client) GetHashField(key, field string) util.Value

GetHashField gets a single value in a hash.

func (*Client) GetHashFields

func (c *Client) GetHashFields(key string, fields []string) (map[string]util.Value, error)

GetHashFields gets multiple hash values.

func (*Client) GetListItem

func (c *Client) GetListItem(key string, index int64) util.Value

GetListItem gets a single item from a list by index, supports negative indexing.

func (*Client) GetMany

func (c *Client) GetMany(keys []string) (map[string]util.Value, error)

GetMany gets multiple values from the cache.

func (*Client) GetWithPrefix

func (c *Client) GetWithPrefix(prefix string) (map[string]util.Value, error)

GetWithPrefix gets the keys with the given prefix.

func (*Client) Has

func (c *Client) Has(key string) (bool, error)

Has checks if the cache has the given key.

func (*Client) HashFields

func (c *Client) HashFields(key string) ([]string, error)

HashFields gets a list of the fields in a hash.

func (*Client) HashHas

func (c *Client) HashHas(key, field string) (bool, error)

HashHas determines if a hash has a given field.

func (*Client) HashLength

func (c *Client) HashLength(key string) (int64, error)

HashLength returns the number of fields in a hash.

func (*Client) HashValues

func (c *Client) HashValues(key string) ([]util.Value, error)

HashValues gets a list of the values in a hash.

func (*Client) IncrementFloat

func (c *Client) IncrementFloat(key string, by float64) (float64, error)

IncrementFloat increments a float stored at the given key by the given number and returns new value.

func (*Client) IncrementInt

func (c *Client) IncrementInt(key string, by int64) (int64, error)

IncrementInt increments an integer stored at the given key by the given number and returns new value.

func (*Client) Keys

func (c *Client) Keys() ([]string, error)

Keys returns a list of valid keys.

func (*Client) KeysWithPrefix

func (c *Client) KeysWithPrefix(prefix string) ([]string, error)

KeysWithPrefix returns a list of keys with the given prefix.

func (*Client) Length

func (c *Client) Length(key string) (int64, error)

Length returns the byte length of the value for the given key.

func (*Client) ListAppend

func (c *Client) ListAppend(key string, v interface{}) error

ListAppend inserts a new item at the end of the list.

func (*Client) ListDelete

func (c *Client) ListDelete(key string, index int64) error

ListDelete removes an item from a list by index.

func (*Client) ListDeleteItem

func (c *Client) ListDeleteItem(key string, v interface{}) (int64, error)

ListDeleteItem removes the first occurrence of value from a list, returns index or -1 if not found.

func (*Client) ListHas

func (c *Client) ListHas(key string, v interface{}) (int64, error)

ListHas determines if a list contains an item, returns index or -1 if not found.

func (*Client) ListInsert

func (c *Client) ListInsert(key string, index int64, v interface{}) error

ListInsert inserts a new item at the given index in the list.

func (*Client) ListLength

func (c *Client) ListLength(key string) (int64, error)

ListLength gets the number of items in a list.

func (*Client) ListLimit

func (c *Client) ListLimit(key string, limit int64) error

ListLimit sets the maximum length of a list, removing items from the top once limit is reached.

func (*Client) ListPopLeft

func (c *Client) ListPopLeft(key string) util.Value

ListPopLeft returns and removes the first item in a list.

func (*Client) ListPopLeftBlock

func (c *Client) ListPopLeftBlock(key string, timeout int64) util.Value

ListPopLeftBlock returns and removes the first item in a list, or waits the given number of seconds for a value, timeout of zero waits forever.

func (*Client) ListPopRight

func (c *Client) ListPopRight(key string) util.Value

ListPopRight returns and removes the last item in a list.

func (*Client) ListPopRightBlock

func (c *Client) ListPopRightBlock(key string, timeout int64) util.Value

ListPopRightBlock returns and removes the last item in a list, or waits the given number of seconds for a value, timeout of zero waits forever.

func (*Client) Lock

func (c *Client) Lock(key string) error

Lock a key from being modified.

func (*Client) LockWithTimeout

func (c *Client) LockWithTimeout(key string, seconds int64) error

LockWithTimeout locks a key, waiting for the given number of seconds if already locked before returning an error.

func (*Client) LogOut

func (c *Client) LogOut()

LogOut removes the cached authentication token, reverting the client to pre-Authenticate state.

func (*Client) NewEventChannel

func (c *Client) NewEventChannel() (ch chan *pb.Event, id int64)

NewEventChannel returns a new Event channel.

func (*Client) RoleAdd

func (c *Client) RoleAdd(role string) error

RoleAdd adds a new role.

func (*Client) RoleDelete

func (c *Client) RoleDelete(role string) error

RoleDelete deletes a specified role.

func (*Client) RoleGet

func (c *Client) RoleGet(role string) ([]*pb.Permission, error)

RoleGet gets detailed role information.

func (*Client) RoleGrantPermission

func (c *Client) RoleGrantPermission(role string, perm *pb.Permission) error

RoleGrantPermission grants a permission of a specified key or range to a specified role.

func (*Client) RoleList

func (c *Client) RoleList() ([]string, error)

RoleList gets a list of all roles.

func (*Client) RoleRevokePermission

func (c *Client) RoleRevokePermission(role string, perm *pb.Permission) error

RoleRevokePermission revokes a key or range permission of a specified key.

func (*Client) Set

func (c *Client) Set(key string, v interface{}) error

Set a value in the cache.

func (*Client) SetExpire

func (c *Client) SetExpire(key string, seconds int64) error

SetExpire sets the expiration on a key in seconds.

func (*Client) SetHashField

func (c *Client) SetHashField(key, field string, v interface{}) error

SetHashField sets a single value in a hash.

func (*Client) SetHashFields

func (c *Client) SetHashFields(key string, vals map[string]util.Value) error

SetHashFields sets multiple values in a hash.

func (*Client) SetListItem

func (c *Client) SetListItem(key string, index int64, v interface{}) error

SetListItem sets a single item in a list by index.

func (*Client) SetLockTimeout

func (c *Client) SetLockTimeout(seconds int64)

SetLockTimeout sets the default timeout in seconds if already locked.

func (*Client) SetMany

func (c *Client) SetMany(vals map[string]util.Value) (map[string]string, error)

SetMany values, returning a map[key]errorText for any util.

func (*Client) SetNX

func (c *Client) SetNX(key string, v interface{}) (bool, error)

SetNX sets a value only if the key doesn't exist, returns true if changed.

func (*Client) Unlock

func (c *Client) Unlock(key string) error

Unlock a key for modification.

func (*Client) UnlockThenSet

func (c *Client) UnlockThenSet(key string, v util.Value) error

UnlockThenSet unlocks a key, then immediately sets its value.

func (*Client) Unwatch

func (c *Client) Unwatch(key string, prefix bool)

Unwatch stops watching for a key change.

func (*Client) UserAdd

func (c *Client) UserAdd(username, password string) error

UserAdd adds a new user.

func (*Client) UserChangePassword

func (c *Client) UserChangePassword(username, password string) error

UserChangePassword changes the password of the specified user.

func (*Client) UserDelete

func (c *Client) UserDelete(username string) error

UserDelete deletes a specified user.

func (*Client) UserGet

func (c *Client) UserGet(username string) ([]string, error)

UserGet gets detailed user information.

func (*Client) UserGrantRole

func (c *Client) UserGrantRole(username, role string) error

UserGrantRole grants a role to a specified user.

func (*Client) UserList

func (c *Client) UserList() ([]string, error)

UserList gets a list of all users.

func (*Client) UserRevokeRole

func (c *Client) UserRevokeRole(username, role string) error

UserRevokeRole revokes a role from a specified user.

func (*Client) Watch

func (c *Client) Watch(key string, prefix bool)

Watch for a key change.

type Config

type Config struct {
	Addresses []string
	TLS       *tls.Config
	AutoTLS   bool
	// contains filtered or unexported fields
}

Config object.

func NewClientConfig

func NewClientConfig(address string) Config

NewClientConfig returns a new ClientConfig with default values.

func NewClientConfigAddresses

func NewClientConfigAddresses(addresses []string) Config

NewClientConfigAddresses returns a new ClientConfig multiple node addresses.

Jump to

Keyboard shortcuts

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