module Database.Memcache.Types (
Authentication(..), Username, Password,
Q(..), K(..), Key, Value, Extras, Initial, Delta, Expiration, Flags,
Version, Status(..),
Header(..), mEMCACHE_HEADER_SIZE, PktType(..),
Request(..), OpRequest(..), SESet(..), SEIncr(..), SETouch(..),
SERaw(..), emptyReq,
Response(..), OpResponse(..), emptyRes
) where
import Blaze.ByteString.Builder (Builder)
import Data.ByteString (ByteString)
import Data.Word
data Authentication
= Auth { Authentication -> Username
username :: !Username, Authentication -> Username
password :: !Password }
| NoAuth
deriving (Authentication -> Authentication -> Bool
(Authentication -> Authentication -> Bool)
-> (Authentication -> Authentication -> Bool) -> Eq Authentication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Authentication -> Authentication -> Bool
== :: Authentication -> Authentication -> Bool
$c/= :: Authentication -> Authentication -> Bool
/= :: Authentication -> Authentication -> Bool
Eq, Int -> Authentication -> ShowS
[Authentication] -> ShowS
Authentication -> String
(Int -> Authentication -> ShowS)
-> (Authentication -> String)
-> ([Authentication] -> ShowS)
-> Show Authentication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Authentication -> ShowS
showsPrec :: Int -> Authentication -> ShowS
$cshow :: Authentication -> String
show :: Authentication -> String
$cshowList :: [Authentication] -> ShowS
showList :: [Authentication] -> ShowS
Show)
type Username = ByteString
type Password = ByteString
mEMCACHE_HEADER_SIZE :: Int
= Int
24
data = {
Header -> Word8
op :: Word8,
Header -> Word16
keyLen :: Word16,
:: Word8,
Header -> Status
status :: Status,
Header -> Word32
bodyLen :: Word32,
Header -> Word32
opaque :: Word32,
Header -> Version
cas :: Version
} deriving (Header -> Header -> Bool
(Header -> Header -> Bool)
-> (Header -> Header -> Bool) -> Eq Header
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Header -> Header -> Bool
== :: Header -> Header -> Bool
$c/= :: Header -> Header -> Bool
/= :: Header -> Header -> Bool
Eq, Int -> Header -> ShowS
[Header] -> ShowS
Header -> String
(Int -> Header -> ShowS)
-> (Header -> String) -> ([Header] -> ShowS) -> Show Header
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Header -> ShowS
showsPrec :: Int -> Header -> ShowS
$cshow :: Header -> String
show :: Header -> String
$cshowList :: [Header] -> ShowS
showList :: [Header] -> ShowS
Show)
data PktType = PktRequest | PktResponse
deriving (PktType -> PktType -> Bool
(PktType -> PktType -> Bool)
-> (PktType -> PktType -> Bool) -> Eq PktType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PktType -> PktType -> Bool
== :: PktType -> PktType -> Bool
$c/= :: PktType -> PktType -> Bool
/= :: PktType -> PktType -> Bool
Eq, Int -> PktType -> ShowS
[PktType] -> ShowS
PktType -> String
(Int -> PktType -> ShowS)
-> (PktType -> String) -> ([PktType] -> ShowS) -> Show PktType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PktType -> ShowS
showsPrec :: Int -> PktType -> ShowS
$cshow :: PktType -> String
show :: PktType -> String
$cshowList :: [PktType] -> ShowS
showList :: [PktType] -> ShowS
Show)
data Q = Loud | Quiet deriving (Q -> Q -> Bool
(Q -> Q -> Bool) -> (Q -> Q -> Bool) -> Eq Q
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Q -> Q -> Bool
== :: Q -> Q -> Bool
$c/= :: Q -> Q -> Bool
/= :: Q -> Q -> Bool
Eq, Int -> Q -> ShowS
[Q] -> ShowS
Q -> String
(Int -> Q -> ShowS) -> (Q -> String) -> ([Q] -> ShowS) -> Show Q
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Q -> ShowS
showsPrec :: Int -> Q -> ShowS
$cshow :: Q -> String
show :: Q -> String
$cshowList :: [Q] -> ShowS
showList :: [Q] -> ShowS
Show)
data K = NoKey | IncludeKey deriving (K -> K -> Bool
(K -> K -> Bool) -> (K -> K -> Bool) -> Eq K
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: K -> K -> Bool
== :: K -> K -> Bool
$c/= :: K -> K -> Bool
/= :: K -> K -> Bool
Eq, Int -> K -> ShowS
[K] -> ShowS
K -> String
(Int -> K -> ShowS) -> (K -> String) -> ([K] -> ShowS) -> Show K
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> K -> ShowS
showsPrec :: Int -> K -> ShowS
$cshow :: K -> String
show :: K -> String
$cshowList :: [K] -> ShowS
showList :: [K] -> ShowS
Show)
type Key = ByteString
type Value = ByteString
type = ByteString
type Initial = Word64
type Delta = Word64
type Expiration = Word32
type Flags = Word32
type Version = Word64
data OpRequest
= ReqGet Q K Key
| ReqSet Q Key Value SESet
| ReqAdd Q Key Value SESet
| ReqReplace Q Key Value SESet
| ReqDelete Q Key
| ReqIncrement Q Key SEIncr
| ReqDecrement Q Key SEIncr
| ReqAppend Q Key Value
| ReqPrepend Q Key Value
| ReqTouch Key SETouch
| ReqGAT Q K Key SETouch
| ReqFlush Q (Maybe SETouch)
| ReqNoop
| ReqVersion
| ReqStat (Maybe Key)
| ReqQuit Q
| ReqSASLList
| ReqSASLStart Key Value
| ReqSASLStep Key Value
| ReqRaw Word8 (Maybe Key) (Maybe Value) SERaw
deriving (OpRequest -> OpRequest -> Bool
(OpRequest -> OpRequest -> Bool)
-> (OpRequest -> OpRequest -> Bool) -> Eq OpRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OpRequest -> OpRequest -> Bool
== :: OpRequest -> OpRequest -> Bool
$c/= :: OpRequest -> OpRequest -> Bool
/= :: OpRequest -> OpRequest -> Bool
Eq, Int -> OpRequest -> ShowS
[OpRequest] -> ShowS
OpRequest -> String
(Int -> OpRequest -> ShowS)
-> (OpRequest -> String)
-> ([OpRequest] -> ShowS)
-> Show OpRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OpRequest -> ShowS
showsPrec :: Int -> OpRequest -> ShowS
$cshow :: OpRequest -> String
show :: OpRequest -> String
$cshowList :: [OpRequest] -> ShowS
showList :: [OpRequest] -> ShowS
Show)
{-# WARNING ReqRaw "This is dangerous; no future compatability guaranteed" #-}
data SESet = SESet Flags Expiration deriving (SESet -> SESet -> Bool
(SESet -> SESet -> Bool) -> (SESet -> SESet -> Bool) -> Eq SESet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SESet -> SESet -> Bool
== :: SESet -> SESet -> Bool
$c/= :: SESet -> SESet -> Bool
/= :: SESet -> SESet -> Bool
Eq, Int -> SESet -> ShowS
[SESet] -> ShowS
SESet -> String
(Int -> SESet -> ShowS)
-> (SESet -> String) -> ([SESet] -> ShowS) -> Show SESet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SESet -> ShowS
showsPrec :: Int -> SESet -> ShowS
$cshow :: SESet -> String
show :: SESet -> String
$cshowList :: [SESet] -> ShowS
showList :: [SESet] -> ShowS
Show)
data SEIncr = SEIncr Initial Delta Expiration deriving (SEIncr -> SEIncr -> Bool
(SEIncr -> SEIncr -> Bool)
-> (SEIncr -> SEIncr -> Bool) -> Eq SEIncr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SEIncr -> SEIncr -> Bool
== :: SEIncr -> SEIncr -> Bool
$c/= :: SEIncr -> SEIncr -> Bool
/= :: SEIncr -> SEIncr -> Bool
Eq, Int -> SEIncr -> ShowS
[SEIncr] -> ShowS
SEIncr -> String
(Int -> SEIncr -> ShowS)
-> (SEIncr -> String) -> ([SEIncr] -> ShowS) -> Show SEIncr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SEIncr -> ShowS
showsPrec :: Int -> SEIncr -> ShowS
$cshow :: SEIncr -> String
show :: SEIncr -> String
$cshowList :: [SEIncr] -> ShowS
showList :: [SEIncr] -> ShowS
Show)
data SETouch = SETouch Expiration deriving (SETouch -> SETouch -> Bool
(SETouch -> SETouch -> Bool)
-> (SETouch -> SETouch -> Bool) -> Eq SETouch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SETouch -> SETouch -> Bool
== :: SETouch -> SETouch -> Bool
$c/= :: SETouch -> SETouch -> Bool
/= :: SETouch -> SETouch -> Bool
Eq, Int -> SETouch -> ShowS
[SETouch] -> ShowS
SETouch -> String
(Int -> SETouch -> ShowS)
-> (SETouch -> String) -> ([SETouch] -> ShowS) -> Show SETouch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SETouch -> ShowS
showsPrec :: Int -> SETouch -> ShowS
$cshow :: SETouch -> String
show :: SETouch -> String
$cshowList :: [SETouch] -> ShowS
showList :: [SETouch] -> ShowS
Show)
data SERaw = SERaw Builder Int
instance Show SERaw where
show :: SERaw -> String
show SERaw
_ = String
"SERaw _"
instance Eq SERaw where
== :: SERaw -> SERaw -> Bool
(==) SERaw
_ SERaw
_ = Bool
False
data Request = Req {
Request -> OpRequest
reqOp :: OpRequest,
Request -> Word32
reqOpaque :: Word32,
Request -> Version
reqCas :: Version
} deriving (Request -> Request -> Bool
(Request -> Request -> Bool)
-> (Request -> Request -> Bool) -> Eq Request
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Request -> Request -> Bool
== :: Request -> Request -> Bool
$c/= :: Request -> Request -> Bool
/= :: Request -> Request -> Bool
Eq, Int -> Request -> ShowS
[Request] -> ShowS
Request -> String
(Int -> Request -> ShowS)
-> (Request -> String) -> ([Request] -> ShowS) -> Show Request
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Request -> ShowS
showsPrec :: Int -> Request -> ShowS
$cshow :: Request -> String
show :: Request -> String
$cshowList :: [Request] -> ShowS
showList :: [Request] -> ShowS
Show)
emptyReq :: Request
emptyReq :: Request
emptyReq = Req { reqOp :: OpRequest
reqOp = OpRequest
ReqNoop, reqOpaque :: Word32
reqOpaque = Word32
0, reqCas :: Version
reqCas = Version
0 }
data OpResponse
= ResGet Q Value Flags
| ResGetK Q Key Value Flags
| ResSet Q
| ResAdd Q
| ResReplace Q
| ResDelete Q
| ResIncrement Q Word64
| ResDecrement Q Word64
| ResAppend Q
| ResPrepend Q
| ResTouch
| ResGAT Q Value Flags
| ResGATK Q Key Value Flags
| ResFlush Q
| ResNoop
| ResVersion Value
| ResStat Key Value
| ResQuit Q
| ResSASLList Value
| ResSASLStart
| ResSASLStep
deriving (OpResponse -> OpResponse -> Bool
(OpResponse -> OpResponse -> Bool)
-> (OpResponse -> OpResponse -> Bool) -> Eq OpResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OpResponse -> OpResponse -> Bool
== :: OpResponse -> OpResponse -> Bool
$c/= :: OpResponse -> OpResponse -> Bool
/= :: OpResponse -> OpResponse -> Bool
Eq, Int -> OpResponse -> ShowS
[OpResponse] -> ShowS
OpResponse -> String
(Int -> OpResponse -> ShowS)
-> (OpResponse -> String)
-> ([OpResponse] -> ShowS)
-> Show OpResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OpResponse -> ShowS
showsPrec :: Int -> OpResponse -> ShowS
$cshow :: OpResponse -> String
show :: OpResponse -> String
$cshowList :: [OpResponse] -> ShowS
showList :: [OpResponse] -> ShowS
Show)
data Status
= NoError
| ErrKeyNotFound
| ErrKeyExists
| ErrValueTooLarge
| ErrInvalidArgs
| ErrItemNotStored
| ErrValueNonNumeric
| ErrUnknownCommand
| ErrOutOfMemory
| SaslAuthFail
| SaslAuthContinue
deriving (Status -> Status -> Bool
(Status -> Status -> Bool)
-> (Status -> Status -> Bool) -> Eq Status
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Status -> Status -> Bool
== :: Status -> Status -> Bool
$c/= :: Status -> Status -> Bool
/= :: Status -> Status -> Bool
Eq, Int -> Status -> ShowS
[Status] -> ShowS
Status -> String
(Int -> Status -> ShowS)
-> (Status -> String) -> ([Status] -> ShowS) -> Show Status
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Status -> ShowS
showsPrec :: Int -> Status -> ShowS
$cshow :: Status -> String
show :: Status -> String
$cshowList :: [Status] -> ShowS
showList :: [Status] -> ShowS
Show)
data Response = Res {
Response -> OpResponse
resOp :: OpResponse,
Response -> Status
resStatus :: Status,
Response -> Word32
resOpaque :: Word32,
Response -> Version
resCas :: Version
} deriving (Response -> Response -> Bool
(Response -> Response -> Bool)
-> (Response -> Response -> Bool) -> Eq Response
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Response -> Response -> Bool
== :: Response -> Response -> Bool
$c/= :: Response -> Response -> Bool
/= :: Response -> Response -> Bool
Eq, Int -> Response -> ShowS
[Response] -> ShowS
Response -> String
(Int -> Response -> ShowS)
-> (Response -> String) -> ([Response] -> ShowS) -> Show Response
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Response -> ShowS
showsPrec :: Int -> Response -> ShowS
$cshow :: Response -> String
show :: Response -> String
$cshowList :: [Response] -> ShowS
showList :: [Response] -> ShowS
Show)
emptyRes :: Response
emptyRes :: Response
emptyRes = Res { resOp :: OpResponse
resOp = OpResponse
ResNoop, resStatus :: Status
resStatus = Status
NoError, resOpaque :: Word32
resOpaque = Word32
0, resCas :: Version
resCas = Version
0 }