Documentation
¶
Index ¶
- Variables
- type Handler
- func (h Handler) Add(cmd common.SetRequest) error
- func (h Handler) Append(cmd common.SetRequest) error
- func (h Handler) Close() error
- func (h Handler) Delete(cmd common.DeleteRequest) error
- func (h Handler) GAT(cmd common.GATRequest) (common.GetResponse, error)
- func (h Handler) Get(cmd common.GetRequest) (<-chan common.GetResponse, <-chan error)
- func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error)
- func (h Handler) Prepend(cmd common.SetRequest) error
- func (h Handler) Replace(cmd common.SetRequest) error
- func (h Handler) Set(cmd common.SetRequest) error
- func (h Handler) Touch(cmd common.TouchRequest) error
- type Opts
Constants ¶
This section is empty.
Variables ¶
var ( MetricBatchNumBatches = metrics.AddCounter("batch_num_batches", nil) MetricBatchFullBatches = metrics.AddCounter("batch_full_batches", nil) MetricBatchTimedoutBatches = metrics.AddCounter("batch_timedout_batches", nil) MetricBatchWriteError = metrics.AddCounter("batch_write_error", nil) MetricBatchReaderProtocolErrors = metrics.AddCounter("batch_reader_proto_errors", nil) )
var ( MetricBatchRelaysCreated = metrics.AddCounter("batch_relay_created", nil) MetricBatchMonitorRuns = metrics.AddCounter("batch_monitor_runs", nil) MetricBatchConnectionsCreated = metrics.AddCounter("batch_connections_created", nil) MetricBatchConnectionFailure = metrics.AddCounter("batch_connection_failure", nil) MetricBatchExpandLoadFactor = metrics.AddCounter("batch_expand_load_factor", nil) MetricBatchExpandOverloadedRatio = metrics.AddCounter("batch_expand_overloaded_ratio", nil) MetricBatchPoolSize = metrics.AddIntGauge("batch_pool_size", nil) MetricBatchLastLoadFactor = metrics.AddFloatGauge("batch_last_load_factor", nil) )
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the handlers.Handler interface. It is an implementation of the interface that defers all requests to a connection pool to the backend. This is done in order to decrease the number of syscalls that the process has to make by batching requests as much as possible per connection. The connection pool is a grow-only style where more connections may be added as needed but they are never torn down.
func NewHandler ¶
NewHandler creates a new handler with the given unix socket as the connected backend. The first time this method is called it creates a background monitor that will add connections as needed for the given domain socket. The Opts parameter can exclude any settings in order to take the defaults. Any setting that is at the 0 value or negative will take the default.
Default values are:
BatchSize: 10, BatchDelayMicros: 250, ReadBufSize: 1 << 16, // 64k WriteBufSize: 1 << 16, // 64k EvaluationIntervalSec: 2, LoadFactorExpandRatio: 0.75, OverloadedConnRatio: 0.2,
func (Handler) Add ¶
func (h Handler) Add(cmd common.SetRequest) error
Add performs an add operation on the backend. It only sets the value if it does not already exist.
func (Handler) Append ¶
func (h Handler) Append(cmd common.SetRequest) error
Append performs an append operation on the backend. It will append the data to the value only if it already exists.
func (Handler) Close ¶
Close does nothing for this Handler as the connections are pooled behind it and are not explicitly controlled.
func (Handler) Delete ¶
func (h Handler) Delete(cmd common.DeleteRequest) error
Delete performs a delete operation on the backend. It will unconditionally remove the value.
func (Handler) GAT ¶
func (h Handler) GAT(cmd common.GATRequest) (common.GetResponse, error)
GAT performs a get-and-touch on the backend for the given key. It will retrieve the value while updating the TTL to the one supplied.
func (Handler) Get ¶
func (h Handler) Get(cmd common.GetRequest) (<-chan common.GetResponse, <-chan error)
Get performs a get operation on the backend. It retrieves the whole of the batch of keys given as a group and returns them one at a time over the request channel.
func (Handler) GetE ¶
func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error)
GetE performs a get-with-expiration on the backend. It is a custom command only implemented in Rend. It retrieves the whole batch of keys given as a group and returns them one at a time over the request channel.
func (Handler) Prepend ¶
func (h Handler) Prepend(cmd common.SetRequest) error
Prepend performs a prepend operation on the backend. It will prepend the data to the value only if it already exists.
func (Handler) Replace ¶
func (h Handler) Replace(cmd common.SetRequest) error
Replace performs a replace operation on the backend. It only sets the value if it already exists.