memcache-0.2.0.0: A memcached client library.

Copyright(c) David Terei, 2016
LicenseBSD
Maintainercode@davidterei.com
Stabilitystable
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Database.Memcache.Cluster

Contents

Description

Handles a group of connections to different Memcached servers.

We use consistent hashing to choose which server to route a request to. On an error, we mark the server as failed and remove it temporarialy from the set of servers available.

Synopsis

Cluster

data Cluster Source

Memcached cluster.

data ServerSpec Source

ServerSpec specifies a server configuration for connection.

Constructors

ServerSpec 

Fields

ssHost :: HostName

Hostname of server to connect to.

ssPort :: PortNumber

Port number server is running on.

ssAuth :: Authentication

Authentication values to use for SASL authentication with this server.

data Options Source

Options specifies how a Memcached cluster should be configured.

Constructors

Options 

Fields

optsServerRetries :: Retries

Number of times to retry an operation on failure. If consecutive failures exceed this value for a server, we mark it as down and failover to a different server for the next operation.

Default is 2.

optsFailRetryDelay :: Milli

After an operation has failed, how long to wait before retrying it while still within the optsServerRetries count?

Default is 200ms.

optsDeadRetryDelay :: Milli

How long to wait after a server has been marked down, before trying to use it again.

Default is 1500ms.

optsServerTimeout :: Milli

How long to wait for an operation to complete before considering it failed.

Default is 750ms.

newCluster :: [ServerSpec] -> Options -> IO Cluster Source

Establish a new connection to a group of Memcached servers.

Operations

type Retries = Int Source

Number of times to retry an operation before considering it failed.

keyedOp :: Cluster -> Key -> Request -> IO Response Source

Run a Memcached operation against a particular server, handling any failures that occur, retrying the specified number of times.

anyOp :: Cluster -> Request -> IO Response Source

Run a Memcached operation against any single server in the cluster, handling any failures that occur, retrying the specified number of times.

allOp :: Cluster -> Request -> IO [(Server, Response)] Source

Run a Memcached operation against all servers in the cluster, handling any failures that occur, retrying the specified number of times.

allOp' :: Cluster -> (Server -> IO a) -> IO [(Server, a)] Source

Run a Memcached operation against all servers in the cluster, handling any failures that occur, retrying the specified number of times. Similar to anyOp but allows more flexible interaction with the Server than a single request and response.