|
@@ -42,87 +42,96 @@ Package memcache provides a client for the memcached cache server.
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+## Types
|
|
|
|
|
+
|
|
|
### type Client
|
|
### type Client
|
|
|
|
|
|
|
|
Client is a memcache client.
|
|
Client is a memcache client.
|
|
|
It is safe for unlocked use by multiple concurrent goroutines.
|
|
It is safe for unlocked use by multiple concurrent goroutines.
|
|
|
|
|
|
|
|
- type Client struct {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ type Client struct {
|
|
|
// TimeoutNanos specifies the socket read/write timeout.
|
|
// TimeoutNanos specifies the socket read/write timeout.
|
|
|
// If zero, DefaultTimeoutNanos is used.
|
|
// If zero, DefaultTimeoutNanos is used.
|
|
|
TimeoutNanos int64
|
|
TimeoutNanos int64
|
|
|
// contains filtered or unexported fields
|
|
// contains filtered or unexported fields
|
|
|
}
|
|
}
|
|
|
- <h3 id="Client.New">func <a href="/src/pkg/github.com/bradfitz/gomemcache/memcache.go?s=3478:3512#L102">New</a></h3>
|
|
|
|
|
- <p><code>func New(server ...string) *Client</code></p>
|
|
|
|
|
- <p>
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+### func New
|
|
|
|
|
+
|
|
|
|
|
+ func New(server ...string) *Client
|
|
|
|
|
+
|
|
|
New returns a memcache client using the provided server(s)
|
|
New returns a memcache client using the provided server(s)
|
|
|
with equal weight. If a server is listed multiple times,
|
|
with equal weight. If a server is listed multiple times,
|
|
|
it gets a proportional amount of weight.
|
|
it gets a proportional amount of weight.
|
|
|
-</p>
|
|
|
|
|
|
|
|
|
|
- <h3 id="Client.NewFromSelector">func <a href="/src/pkg/github.com/bradfitz/gomemcache/memcache.go?s=3670:3717#L109">NewFromSelector</a></h3>
|
|
|
|
|
- <p><code>func NewFromSelector(ss ServerSelector) *Client</code></p>
|
|
|
|
|
- <p>
|
|
|
|
|
|
|
+### func NewFromSelector
|
|
|
|
|
+
|
|
|
|
|
+ func NewFromSelector(ss ServerSelector) *Client
|
|
|
|
|
+
|
|
|
NewFromSelector returns a new Client using the provided ServerSelector.
|
|
NewFromSelector returns a new Client using the provided ServerSelector.
|
|
|
-</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### func (*Client) Add
|
|
#### func (*Client) Add
|
|
|
|
|
|
|
|
- func (c *Client) Add(item *Item) os.Error
|
|
|
|
|
- Add writes the given item, if no value already exists for its
|
|
|
|
|
-key. ErrNotStored is returned if that condition is not met.
|
|
|
|
|
|
|
+ func (c *Client) Add(item *Item) os.Error
|
|
|
|
|
|
|
|
|
|
+Add writes the given item, if no value already exists for its
|
|
|
|
|
+key. ErrNotStored is returned if that condition is not met.
|
|
|
#### func (*Client) CompareAndSwap
|
|
#### func (*Client) CompareAndSwap
|
|
|
|
|
|
|
|
- func (c *Client) CompareAndSwap(item *Item) os.Error
|
|
|
|
|
- CompareAndSwap writes the given item that was previously returned
|
|
|
|
|
|
|
+ func (c *Client) CompareAndSwap(item *Item) os.Error
|
|
|
|
|
+
|
|
|
|
|
+CompareAndSwap writes the given item that was previously returned
|
|
|
by Get, if the value was neither modified or evicted between the
|
|
by Get, if the value was neither modified or evicted between the
|
|
|
Get and the CompareAndSwap calls. The item's Key should not change
|
|
Get and the CompareAndSwap calls. The item's Key should not change
|
|
|
between calls but all other item fields may differ. ErrCASConflict
|
|
between calls but all other item fields may differ. ErrCASConflict
|
|
|
is returned if the value was modified in between the
|
|
is returned if the value was modified in between the
|
|
|
calls. ErrNotStored is returned if the value was evicted in between
|
|
calls. ErrNotStored is returned if the value was evicted in between
|
|
|
the calls.
|
|
the calls.
|
|
|
-
|
|
|
|
|
#### func (*Client) Delete
|
|
#### func (*Client) Delete
|
|
|
|
|
|
|
|
- func (c *Client) Delete(key string) os.Error
|
|
|
|
|
- Delete deletes the item with the provided key. The error ErrCacheMiss is
|
|
|
|
|
-returned if the item didn't already exist in the cache.
|
|
|
|
|
|
|
+ func (c *Client) Delete(key string) os.Error
|
|
|
|
|
|
|
|
|
|
+Delete deletes the item with the provided key. The error ErrCacheMiss is
|
|
|
|
|
+returned if the item didn't already exist in the cache.
|
|
|
#### func (*Client) DeleteLock
|
|
#### func (*Client) DeleteLock
|
|
|
|
|
|
|
|
- func (c *Client) DeleteLock(key string, seconds int) os.Error
|
|
|
|
|
- Delete deletes the item with the provided key, also instructing the
|
|
|
|
|
|
|
+ func (c *Client) DeleteLock(key string, seconds int) os.Error
|
|
|
|
|
+
|
|
|
|
|
+Delete deletes the item with the provided key, also instructing the
|
|
|
server to not permit an "add" or "replace" commands to work on the
|
|
server to not permit an "add" or "replace" commands to work on the
|
|
|
key for the given duration (in seconds). The error ErrCacheMiss is
|
|
key for the given duration (in seconds). The error ErrCacheMiss is
|
|
|
returned if the item didn't already exist in the cache.
|
|
returned if the item didn't already exist in the cache.
|
|
|
-
|
|
|
|
|
#### func (*Client) Get
|
|
#### func (*Client) Get
|
|
|
|
|
|
|
|
- func (c *Client) Get(key string) (item *Item, err os.Error)
|
|
|
|
|
- Get gets the item for the given key. ErrCacheMiss is returned for a
|
|
|
|
|
-memcache cache miss. The key must be at most 250 bytes in length.
|
|
|
|
|
|
|
+ func (c *Client) Get(key string) (item *Item, err os.Error)
|
|
|
|
|
|
|
|
|
|
+Get gets the item for the given key. ErrCacheMiss is returned for a
|
|
|
|
|
+memcache cache miss. The key must be at most 250 bytes in length.
|
|
|
#### func (*Client) GetMulti
|
|
#### func (*Client) GetMulti
|
|
|
|
|
|
|
|
- func (c *Client) GetMulti(keys []string) (map[string]*Item, os.Error)
|
|
|
|
|
- GetMulti is a batch version of Get. The returned map from keys to
|
|
|
|
|
|
|
+ func (c *Client) GetMulti(keys []string) (map[string]*Item, os.Error)
|
|
|
|
|
+
|
|
|
|
|
+GetMulti is a batch version of Get. The returned map from keys to
|
|
|
items may have fewer elements than the input slice, due to memcache
|
|
items may have fewer elements than the input slice, due to memcache
|
|
|
cache misses. Each key must be at most 250 bytes in length.
|
|
cache misses. Each key must be at most 250 bytes in length.
|
|
|
If no error is returned, the returned map will also be non-nil.
|
|
If no error is returned, the returned map will also be non-nil.
|
|
|
-
|
|
|
|
|
#### func (*Client) Set
|
|
#### func (*Client) Set
|
|
|
|
|
|
|
|
- func (c *Client) Set(item *Item) os.Error
|
|
|
|
|
- Set writes the given item, unconditionally.
|
|
|
|
|
|
|
+ func (c *Client) Set(item *Item) os.Error
|
|
|
|
|
+
|
|
|
|
|
+Set writes the given item, unconditionally.
|
|
|
|
|
+
|
|
|
|
|
|
|
|
### type Item
|
|
### type Item
|
|
|
|
|
|
|
|
Item is an item to be got or stored in a memcached server.
|
|
Item is an item to be got or stored in a memcached server.
|
|
|
|
|
|
|
|
- type Item struct {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ type Item struct {
|
|
|
// Key is the Item's key (250 bytes maximum).
|
|
// Key is the Item's key (250 bytes maximum).
|
|
|
Key string
|
|
Key string
|
|
|
|
|
|
|
@@ -143,22 +152,32 @@ Item is an item to be got or stored in a memcached server.
|
|
|
// contains filtered or unexported fields
|
|
// contains filtered or unexported fields
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
### type ServerList
|
|
### type ServerList
|
|
|
|
|
|
|
|
ServerList is a simple ServerSelector. Its zero value is usable.
|
|
ServerList is a simple ServerSelector. Its zero value is usable.
|
|
|
|
|
|
|
|
- type ServerList struct {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ type ServerList struct {
|
|
|
// contains filtered or unexported fields
|
|
// contains filtered or unexported fields
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
#### func (*ServerList) PickServer
|
|
#### func (*ServerList) PickServer
|
|
|
|
|
|
|
|
- func (ss *ServerList) PickServer(key string) (net.Addr, os.Error)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ func (ss *ServerList) PickServer(key string) (net.Addr, os.Error)
|
|
|
|
|
+
|
|
|
#### func (*ServerList) SetServers
|
|
#### func (*ServerList) SetServers
|
|
|
|
|
|
|
|
- func (ss *ServerList) SetServers(servers ...string) os.Error
|
|
|
|
|
- SetServers changes a ServerList's set of servers at runtime and is
|
|
|
|
|
|
|
+ func (ss *ServerList) SetServers(servers ...string) os.Error
|
|
|
|
|
+
|
|
|
|
|
+SetServers changes a ServerList's set of servers at runtime and is
|
|
|
threadsafe.
|
|
threadsafe.
|
|
|
|
|
|
|
|
Each server is given equal weight. A server is given more weight
|
|
Each server is given equal weight. A server is given more weight
|
|
@@ -168,6 +187,7 @@ SetServers returns an error if any of the server names fail to
|
|
|
resolve. No attempt is made to connect to the server. If any error
|
|
resolve. No attempt is made to connect to the server. If any error
|
|
|
is returned, no changes are made to the ServerList.
|
|
is returned, no changes are made to the ServerList.
|
|
|
|
|
|
|
|
|
|
+
|
|
|
### type ServerSelector
|
|
### type ServerSelector
|
|
|
|
|
|
|
|
ServerSelector is the interface that selects a memcache server
|
|
ServerSelector is the interface that selects a memcache server
|
|
@@ -175,10 +195,17 @@ as a function of the item's key.
|
|
|
|
|
|
|
|
All ServerSelector implementations must be threadsafe.
|
|
All ServerSelector implementations must be threadsafe.
|
|
|
|
|
|
|
|
- type ServerSelector interface {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ type ServerSelector interface {
|
|
|
// PickServer returns the server address that a given item
|
|
// PickServer returns the server address that a given item
|
|
|
// should be shared onto.
|
|
// should be shared onto.
|
|
|
PickServer(key string) (net.Addr, os.Error)
|
|
PickServer(key string) (net.Addr, os.Error)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|