Safe Haskell | None |
---|---|
Language | Haskell2010 |
A memcache client. Supports the binary protocol (only) and SASL authentication.
A client can connect to a single memcache server or a cluster of them. In the later case, consistent hashing is used to route requests to the appropriate server.
Expected return values (like misses) are returned as part of the return type, while unexpected errors are thrown as exceptions.
- newClient :: [ServerSpec] -> Options -> IO Client
- type Client = Cluster
- data ServerSpec = ServerSpec {}
- defaultServerSpec :: ServerSpec
- data Options = Options {
- optsCmdFailure :: !FailureMode
- optsServerFailure :: !FailureMode
- optsServerRetries :: !Int
- defaultOptions :: Options
- data Authentication
- type Username = ByteString
- type Password = ByteString
- get :: Cluster -> Key -> IO (Maybe (Value, Flags, Version))
- gat :: Cluster -> Key -> Expiration -> IO (Maybe (Value, Flags, Version))
- touch :: Cluster -> Key -> Expiration -> IO (Maybe Version)
- set :: Cluster -> Key -> Value -> Flags -> Expiration -> IO Version
- set' :: Cluster -> Key -> Value -> Flags -> Expiration -> Version -> IO (Maybe Version)
- add :: Cluster -> Key -> Value -> Flags -> Expiration -> IO (Maybe Version)
- replace :: Cluster -> Key -> Value -> Flags -> Expiration -> Version -> IO (Maybe Version)
- delete :: Cluster -> Key -> Version -> IO Bool
- flush :: Cluster -> Maybe Expiration -> IO ()
- increment :: Cluster -> Key -> Initial -> Delta -> Expiration -> Version -> IO (Maybe (Word64, Version))
- decrement :: Cluster -> Key -> Initial -> Delta -> Expiration -> Version -> IO (Maybe (Word64, Version))
- append :: Cluster -> Key -> Value -> Version -> IO (Maybe Version)
- prepend :: Cluster -> Key -> Value -> Version -> IO (Maybe Version)
- version :: Cluster -> IO ByteString
- stats :: Cluster -> Maybe Key -> IO [(Server, Maybe StatResults)]
- type StatResults = [(ByteString, ByteString)]
- quit :: Cluster -> IO ()
- data MemcacheError
- data ClientError = NotEnoughBytes
Cluster and connection handling
data ServerSpec Source
ServerSpec specifies a server configuration to connect to.
ServerSpec | |
|
defaultServerSpec :: ServerSpec Source
Provides a default value for a server cconnection config.
Options specifies how a memcache cluster should be configured.
Options | |
|
defaultOptions :: Options Source
Provides recommended default for a cluster Options.
data Authentication Source
SASL Authentication information for a server.
type Username = ByteString Source
Username for authentication.
type Password = ByteString Source
Password for authentication.
Get operations
Set operations
Delete operations
Modify operations
increment :: Cluster -> Key -> Initial -> Delta -> Expiration -> Version -> IO (Maybe (Word64, Version)) Source
decrement :: Cluster -> Key -> Initial -> Delta -> Expiration -> Version -> IO (Maybe (Word64, Version)) Source
Information operations
version :: Cluster -> IO ByteString Source
Version returns the version string of the memcached cluster. We just query one server and assume all servers in the cluster are the same version.
type StatResults = [(ByteString, ByteString)] Source
StatResults are a list of key-value pairs.
Error handling
data MemcacheError Source
Exceptions that may be thrown by Memcache. These are expected error codes returned by a memcached server.
data ClientError Source
Errors that occur between the client and server in communicating. These are unexpected exceptions, such as network failures or garbage data.