-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A memcached client library.
--
@package memcache
@version 0.0.1
-- | Stores the various types needed by memcache. Mostly concerned with the
-- representation of the protocol.
module Database.Memcache.Types
data Q
Loud :: Q
Quiet :: Q
data K
NoKey :: K
IncludeKey :: K
type Key = ByteString
type Value = ByteString
type Extras = ByteString
type Initial = Word64
type Delta = Word64
type Expiration = Word32
type Flags = Word32
type Version = Word64
mEMCACHE_HEADER_SIZE :: Int
data Header
Header :: Word8 -> Word16 -> Word8 -> Status -> Word32 -> Word32 -> Version -> Header
op :: Header -> Word8
keyLen :: Header -> Word16
extraLen :: Header -> Word8
status :: Header -> Status
bodyLen :: Header -> Word32
opaque :: Header -> Word32
cas :: Header -> Version
data Request
Req :: OpRequest -> Word32 -> Version -> Request
reqOp :: Request -> OpRequest
reqOpaque :: Request -> Word32
reqCas :: Request -> Version
data OpRequest
ReqGet :: Q -> K -> Key -> OpRequest
ReqSet :: Q -> Key -> Value -> SESet -> OpRequest
ReqAdd :: Q -> Key -> Value -> SESet -> OpRequest
ReqReplace :: Q -> Key -> Value -> SESet -> OpRequest
ReqDelete :: Q -> Key -> OpRequest
ReqIncrement :: Q -> Key -> SEIncr -> OpRequest
ReqDecrement :: Q -> Key -> SEIncr -> OpRequest
ReqAppend :: Q -> Key -> Value -> OpRequest
ReqPrepend :: Q -> Key -> Value -> OpRequest
ReqTouch :: Key -> SETouch -> OpRequest
ReqGAT :: Q -> K -> Key -> SETouch -> OpRequest
ReqFlush :: Q -> (Maybe SETouch) -> OpRequest
ReqNoop :: OpRequest
ReqVersion :: OpRequest
ReqStat :: (Maybe Key) -> OpRequest
ReqQuit :: Q -> OpRequest
ReqSASLList :: OpRequest
ReqSASLStart :: Key -> Value -> OpRequest
ReqSASLStep :: Key -> Value -> OpRequest
data SESet
SESet :: Flags -> Expiration -> SESet
data SEIncr
SEIncr :: Initial -> Delta -> Expiration -> SEIncr
data SETouch
SETouch :: Expiration -> SETouch
emptyReq :: Request
data Response
Res :: OpResponse -> Status -> Word32 -> Version -> Response
resOp :: Response -> OpResponse
resStatus :: Response -> Status
resOpaque :: Response -> Word32
resCas :: Response -> Version
data OpResponse
ResGet :: Q -> Value -> Flags -> OpResponse
ResGetK :: Q -> Key -> Value -> Flags -> OpResponse
ResSet :: Q -> OpResponse
ResAdd :: Q -> OpResponse
ResReplace :: Q -> OpResponse
ResDelete :: Q -> OpResponse
ResIncrement :: Q -> Word64 -> OpResponse
ResDecrement :: Q -> Word64 -> OpResponse
ResAppend :: Q -> OpResponse
ResPrepend :: Q -> OpResponse
ResTouch :: OpResponse
ResGAT :: Q -> Value -> Flags -> OpResponse
ResGATK :: Q -> Key -> Value -> Flags -> OpResponse
ResFlush :: Q -> OpResponse
ResNoop :: OpResponse
ResVersion :: Value -> OpResponse
ResStat :: Key -> Value -> OpResponse
ResQuit :: Q -> OpResponse
ResSASLList :: Value -> OpResponse
ResSASLStart :: OpResponse
ResSASLStep :: OpResponse
data Status
NoError :: Status
ErrKeyNotFound :: Status
ErrKeyExists :: Status
ErrValueTooLarge :: Status
ErrInvalidArgs :: Status
ErrItemNotStored :: Status
ErrValueNonNumeric :: Status
ErrUnknownCommand :: Status
ErrOutOfMemory :: Status
SaslAuthFail :: Status
SaslAuthContinue :: Status
data ProtocolError
ProtocolError :: String -> Maybe Header -> [String] -> ProtocolError
protocolMessage :: ProtocolError -> String
protocolHeader :: ProtocolError -> Maybe Header
protocolParams :: ProtocolError -> [String]
data IncorrectResponse
IncorrectResponse :: String -> Response -> IncorrectResponse
increspMessage :: IncorrectResponse -> String
increspActual :: IncorrectResponse -> Response
instance Typeable Q
instance Typeable K
instance Typeable SESet
instance Typeable SEIncr
instance Typeable SETouch
instance Typeable OpRequest
instance Typeable Request
instance Typeable OpResponse
instance Typeable Status
instance Typeable Response
instance Typeable Header
instance Typeable ProtocolError
instance Typeable IncorrectResponse
instance Eq Q
instance Show Q
instance Eq K
instance Show K
instance Eq SESet
instance Show SESet
instance Eq SEIncr
instance Show SEIncr
instance Eq SETouch
instance Show SETouch
instance Eq OpRequest
instance Show OpRequest
instance Eq Request
instance Show Request
instance Eq OpResponse
instance Show OpResponse
instance Eq Status
instance Show Status
instance Eq Response
instance Show Response
instance Eq Header
instance Show Header
instance Eq ProtocolError
instance Show ProtocolError
instance Eq IncorrectResponse
instance Show IncorrectResponse
instance Exception IncorrectResponse
instance Exception ProtocolError
-- | Memcache related errors and exception handling.
module Database.Memcache.Errors
-- | Exceptions that may be thrown by Memcache. These are expected error
-- codes returned by a memcached server.
data MemcacheError
MemErrNoKey :: MemcacheError
MemErrKeyExists :: MemcacheError
MemErrValueTooLarge :: MemcacheError
MemErrInvalidArgs :: MemcacheError
MemErrStoreFailed :: MemcacheError
MemErrValueNonNumeric :: MemcacheError
MemErrUnknownCmd :: MemcacheError
MemErrOutOfMemory :: MemcacheError
-- | Convert a status to an error. Note, not all status's are errors and so
-- this is a partial function!
statusToError :: Status -> MemcacheError
-- | Convert a status to an exception. Note, not all status's are errors
-- and so this is not a complete function!
throwStatus :: Response -> IO a
-- | Throw an IncorrectResponse exception for a wrong received response.
throwIncorrectRes :: Response -> String -> IO a
-- | Errors that occur between the client and server in communicating.
-- These are unexpected exceptions, such as network failures or garbage
-- data.
data ClientError
NotEnoughBytes :: ClientError
instance Typeable MemcacheError
instance Typeable ClientError
instance Eq MemcacheError
instance Show MemcacheError
instance Eq ClientError
instance Show ClientError
instance Exception ClientError
instance Exception MemcacheError
-- | Deals with serializing and parsing memcached requests and responses.
module Database.Memcache.Wire
-- | Serialize a request to a ByteString Builder.
szRequest :: Request -> Builder
-- | Serialize a request to a ByteString.
szRequest' :: Request -> ByteString
-- | Deserialize a Response.
dzResponse :: Get Response
-- | Deserialize a Response from a ByteString.
dzResponse' :: ByteString -> Response
-- | Deserialize a Header.
dzHeader :: Get Header
-- | Deserialize a Header from a ByteString.
dzHeader' :: ByteString -> Header
-- | Deserialize a Response body.
dzBody :: Header -> Get Response
-- | Deserialize a Response body from a ByteString.
dzBody' :: Header -> ByteString -> Response
-- | Handles the connections between a memcache client and a single server.
module Database.Memcache.Server
-- | A memcached server connection.
data Server
-- | Create a new memcached connection.
newServer :: HostName -> PortNumber -> IO Server
-- | Send and receive a single request/response pair to the memcached
-- server.
sendRecv :: Server -> Request -> IO Response
-- | Run a function with access to an server socket for using send
-- and recv.
withSocket :: Server -> (Socket -> IO a) -> IO a
-- | Send a request to the memcached server.
send :: Socket -> Request -> IO ()
-- | Retrieve a single response from the memcached server. TODO: read into
-- buffer to minimize read syscalls
recv :: Socket -> IO Response
-- | Close the server connection. If you perform another operation after
-- this, the connection will be re-established.
close :: Server -> IO ()
instance Show Server
instance Ord Server
instance Eq Server
-- | SASL authentication support for memcached.
module Database.Memcache.SASL
-- | Perform SASL authentication with the server.
authenticate :: Server -> Username -> Password -> IO Bool
-- | Username for authentication.
type Username = ByteString
-- | Password for authentication.
type Password = ByteString
-- | A raw, low level interface to the memcache protocol.
--
-- The various operations are represented in full as they appear at the
-- protocol level and so aren't generally well suited for application
-- use. Instead, applications should use Database.Memcache.Client which
-- presents a higher level API suited for application use.
module Database.Memcache.Protocol
get :: Server -> Key -> IO (Maybe (Value, Flags, Version))
gat :: Server -> Key -> Expiration -> IO (Maybe (Value, Flags, Version))
touch :: Server -> Key -> Expiration -> IO (Maybe Version)
set :: Server -> Key -> Value -> Flags -> Expiration -> IO Version
set' :: Server -> Key -> Value -> Flags -> Expiration -> Version -> IO (Maybe Version)
add :: Server -> Key -> Value -> Flags -> Expiration -> IO (Maybe Version)
replace :: Server -> Key -> Value -> Flags -> Expiration -> Version -> IO (Maybe Version)
delete :: Server -> Key -> Version -> IO Bool
increment :: Server -> Key -> Initial -> Delta -> Expiration -> Version -> IO (Maybe (Word64, Version))
decrement :: Server -> Key -> Initial -> Delta -> Expiration -> Version -> IO (Maybe (Word64, Version))
append :: Server -> Key -> Value -> Version -> IO (Maybe Version)
prepend :: Server -> Key -> Value -> Version -> IO (Maybe Version)
-- | StatResults are a list of key-value pairs.
type StatResults = [(ByteString, ByteString)]
stats :: Server -> Maybe Key -> IO (Maybe StatResults)
flush :: Server -> Maybe Expiration -> IO ()
noop :: Server -> IO ()
version :: Server -> IO ByteString
quit :: Server -> IO ()
-- | Handles a group of connections to different memcache servers.
module Database.Memcache.Cluster
-- | A memcached cluster.
data Cluster
-- | Establish a new connection to a group of memcached servers.
newMemcacheCluster :: [(HostName, PortNumber)] -> Options -> IO Cluster
data Options
Options :: !FailureMode -> !FailureMode -> !Int -> Options
optsCmdFailure :: Options -> !FailureMode
optsServerFailure :: Options -> !FailureMode
optsServerRetries :: Options -> !Int
defaultOptions :: Options
-- | Run a memcache operation against a server that maps to the key given
-- in the cluster.
keyedOp :: Maybe a -> Cluster -> Key -> (Server -> IO a) -> IO a
-- | Run a memcache operation against any single server in the cluster.
anyOp :: Maybe a -> Cluster -> (Server -> IO a) -> IO a
-- | Run a memcache operation against all servers in the cluster.
allOp :: Maybe a -> Cluster -> (Server -> IO a) -> IO [(Server, a)]
instance Eq FailureMode
instance Show FailureMode
instance Show Cluster
-- | A memcache client.
module Database.Memcache.Client
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
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)
flush :: Cluster -> Maybe Expiration -> IO ()
-- | 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.
version :: Cluster -> IO ByteString
stats :: Cluster -> Maybe Key -> IO ([(Server, Maybe StatResults)])
quit :: Cluster -> IO ()