Documentation ¶
Overview ¶
Package client implements a Golang client to access an OlricDB cluster from outside.
Index ¶
- type Client
- func (c *Client) Close()
- func (c *Client) Delete(name, key string) error
- func (c *Client) Destroy(name string) error
- func (c *Client) Get(name, key string) (interface{}, error)
- func (c *Client) LockWithTimeout(name, key string, timeout time.Duration) error
- func (c *Client) Put(name, key string, value interface{}) error
- func (c *Client) PutEx(name, key string, value interface{}, timeout time.Duration) error
- func (c *Client) Unlock(name, key string) error
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 represents a Golang client to access an OlricDB cluster from outside.
func New ¶
New returns a new Client object. The second parameter is http.Client. It can be nil. Server names have to be start with protocol scheme: http or https.
func (*Client) Close ¶
func (c *Client) Close()
Close cancels underlying context and cancels ongoing requests.
func (*Client) Delete ¶
Delete deletes the value for the given key. Delete will not return error if key doesn't exist. It's thread-safe. It is safe to modify the contents of the argument after Delete returns.
func (*Client) Destroy ¶
Destroy flushes the given DMap on the cluster. You should know that there is no global lock on DMaps. So if you call Put/PutEx and Destroy methods concurrently on the cluster, Put/PutEx calls may set new values to the DMap.
func (*Client) Get ¶
Get gets the value for the given key. It returns ErrKeyNotFound if the DB does not contains the key. It's thread-safe. It is safe to modify the contents of the returned value. It is safe to modify the contents of the argument after Get returns.
func (*Client) LockWithTimeout ¶
LockWithTimeout sets a lock for the given key. If the lock is still unreleased the end of given period of time, it automatically releases the lock. Acquired lock is only for the key in this map. Please note that, before setting a lock for a key, you should set the key with Put method. Otherwise it returns olricdb.ErrKeyNotFound error.
It returns immediately if it acquires the lock for the given key. Otherwise, it waits until timeout. The timeout is determined by http.Client which can be configured via Config structure.
You should know that the locks are approximate, and only to be used for non-critical purposes.
func (*Client) Put ¶
Put sets the value for the given key. It overwrites any previous value for that key and it's thread-safe. It is safe to modify the contents of the arguments after Put returns but not before.