| Safe Haskell | None |
|---|
Database.Monarch
Description
This module provide TokyoTyrant monadic access interface.
- type Monarch = MonarchT IO
- data MonarchT m a
- data Connection
- type ConnectionPool = Pool Connection
- withMonarchConn :: (MonadBaseControl IO m, MonadIO m) => String -> Int -> (Connection -> m a) -> m a
- withMonarchPool :: (MonadBaseControl IO m, MonadIO m) => String -> Int -> Int -> (ConnectionPool -> m a) -> m a
- runMonarchConn :: (MonadBaseControl IO m, MonadIO m) => MonarchT m a -> Connection -> m (Either Code a)
- runMonarchPool :: (MonadBaseControl IO m, MonadIO m) => MonarchT m a -> ConnectionPool -> m (Either Code a)
- data ExtOption
- data RestoreOption = ConsistencyChecking
- data MiscOption = NoUpdateLog
- data Code
- put :: (MonadBaseControl IO m, MonadIO m) => ByteString -> ByteString -> MonarchT m ()
- putKeep :: (MonadBaseControl IO m, MonadIO m) => ByteString -> ByteString -> MonarchT m ()
- putCat :: (MonadBaseControl IO m, MonadIO m) => ByteString -> ByteString -> MonarchT m ()
- putShiftLeft :: (MonadBaseControl IO m, MonadIO m) => ByteString -> ByteString -> Int -> MonarchT m ()
- putNoResponse :: (MonadBaseControl IO m, MonadIO m) => ByteString -> ByteString -> MonarchT m ()
- out :: (MonadBaseControl IO m, MonadIO m) => ByteString -> MonarchT m ()
- get :: (MonadBaseControl IO m, MonadIO m) => ByteString -> MonarchT m (Maybe ByteString)
- multipleGet :: (MonadBaseControl IO m, MonadIO m) => [ByteString] -> MonarchT m [(ByteString, ByteString)]
- valueSize :: (MonadBaseControl IO m, MonadIO m) => ByteString -> MonarchT m (Maybe Int)
- iterInit :: (MonadBaseControl IO m, MonadIO m) => MonarchT m ()
- iterNext :: (MonadBaseControl IO m, MonadIO m) => MonarchT m (Maybe ByteString)
- forwardMatchingKeys :: (MonadBaseControl IO m, MonadIO m) => ByteString -> Maybe Int -> MonarchT m [ByteString]
- addInt :: (MonadBaseControl IO m, MonadIO m) => ByteString -> Int -> MonarchT m Int
- addDouble :: (MonadBaseControl IO m, MonadIO m) => ByteString -> Double -> MonarchT m Double
- ext :: (MonadBaseControl IO m, MonadIO m) => ByteString -> [ExtOption] -> ByteString -> ByteString -> MonarchT m ByteString
- sync :: (MonadBaseControl IO m, MonadIO m) => MonarchT m ()
- optimize :: (MonadBaseControl IO m, MonadIO m) => ByteString -> MonarchT m ()
- vanish :: (MonadBaseControl IO m, MonadIO m) => MonarchT m ()
- copy :: (MonadBaseControl IO m, MonadIO m) => ByteString -> MonarchT m ()
- restore :: (MonadBaseControl IO m, MonadIO m, Integral a) => ByteString -> a -> [RestoreOption] -> MonarchT m ()
- setMaster :: (MonadBaseControl IO m, MonadIO m, Integral a) => ByteString -> Int -> a -> [RestoreOption] -> MonarchT m ()
- recordNum :: (MonadBaseControl IO m, MonadIO m) => MonarchT m Int64
- size :: (MonadBaseControl IO m, MonadIO m) => MonarchT m Int64
- status :: (MonadBaseControl IO m, MonadIO m) => MonarchT m ByteString
- misc :: (MonadBaseControl IO m, MonadIO m) => ByteString -> [MiscOption] -> [ByteString] -> MonarchT m [ByteString]
Documentation
The Monarch monad transformer to provide TokyoTyrant access.
Instances
| MonadTrans MonarchT | |
| MonadTransControl MonarchT | |
| (Applicative base, Applicative (MonarchT m), Monad base, Monad (MonarchT m), MonadBase base m) => MonadBase base (MonarchT m) | |
| (MonadBase base (MonarchT m), MonadBaseControl base m) => MonadBaseControl base (MonarchT m) | |
| (Monad (MonarchT m), Monad m) => MonadError Code (MonarchT m) | |
| (Monad (MonarchT m), Monad m) => MonadReader Connection (MonarchT m) | |
| Monad m => Monad (MonarchT m) | |
| Functor m => Functor (MonarchT m) | |
| (Functor (MonarchT m), Monad m, Functor m) => Applicative (MonarchT m) | |
| (Monad (MonarchT m), MonadIO m) => MonadIO (MonarchT m) |
data Connection Source
Connection with TokyoTyrant
Instances
| (Monad (MonarchT m), Monad m) => MonadReader Connection (MonarchT m) |
type ConnectionPool = Pool ConnectionSource
Connection pool with TokyoTyrant
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => String | host |
| -> Int | port |
| -> (Connection -> m a) | |
| -> m a |
Create a TokyoTyrant connection and run the given action.
Don't use the given Connection outside the action.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => String | host |
| -> Int | port |
| -> Int | number of connections |
| -> (ConnectionPool -> m a) | |
| -> m a |
Create a TokyoTyrant connection pool and run the given action.
Don't use the given ConnectionPool outside the action.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => MonarchT m a | action |
| -> Connection | connection |
| -> m (Either Code a) |
Run action with a connection.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => MonarchT m a | action |
| -> ConnectionPool | connection pool |
| -> m (Either Code a) |
Run action with a unused connection from the pool.
Options for scripting extension
Constructors
| RecordLocking | record locking |
| GlobalLocking | global locking |
Instances
| BitFlag32 ExtOption |
data RestoreOption Source
Options for restore
Constructors
| ConsistencyChecking | consistency checking |
Instances
| BitFlag32 RestoreOption |
data MiscOption Source
Options for miscellaneous operation
Constructors
| NoUpdateLog | omission of update log |
Instances
| BitFlag32 MiscOption |
Error code
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> ByteString | value |
| -> MonarchT m () |
Store a record. If a record with the same key exists in the database, it is overwritten.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> ByteString | value |
| -> MonarchT m () |
Store a new record. If a record with the same key exists in the database, this function has no effect.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> ByteString | value |
| -> MonarchT m () |
Concatenate a value at the end of the existing record. If there is no corresponding record, a new record is created.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> ByteString | value |
| -> Int | width |
| -> MonarchT m () |
Concatenate a value at the end of the existing record and shift it to the left. If there is no corresponding record, a new record is created.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> ByteString | value |
| -> MonarchT m () |
Store a record without response. If a record with the same key exists in the database, it is overwritten.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> MonarchT m () |
Remove a record.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> MonarchT m (Maybe ByteString) |
Retrieve a record.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => [ByteString] | keys |
| -> MonarchT m [(ByteString, ByteString)] |
Retrieve records.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> MonarchT m (Maybe Int) |
Get the size of the value of a record.
iterNext :: (MonadBaseControl IO m, MonadIO m) => MonarchT m (Maybe ByteString)Source
Get the next key of the iterator. The iterator can be updated by multiple connections and then it is not assured that every record is traversed.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key prefix |
| -> Maybe Int | maximum number of keys to be fetched. |
| -> MonarchT m [ByteString] |
Get forward matching keys.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> Int | value |
| -> MonarchT m Int |
Add an integer to a record. If the corresponding record exists, the value is treated as an integer and is added to. If no record corresponds, a new record of the additional value is stored.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | key |
| -> Double | value |
| -> MonarchT m Double |
Add a real number to a record. If the corresponding record exists, the value is treated as a real number and is added to. If no record corresponds, a new record of the additional value is stored.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | function |
| -> [ExtOption] | option flags |
| -> ByteString | key |
| -> ByteString | value |
| -> MonarchT m ByteString |
Call a function of the script language extension.
sync :: (MonadBaseControl IO m, MonadIO m) => MonarchT m ()Source
Synchronize updated contents with the file and the device.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | parameter |
| -> MonarchT m () |
Optimize the storage.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | path |
| -> MonarchT m () |
Copy the database file.
Arguments
| :: (MonadBaseControl IO m, MonadIO m, Integral a) | |
| => ByteString | path |
| -> a | beginning time stamp in microseconds |
| -> [RestoreOption] | option flags |
| -> MonarchT m () |
Restore the database file from the update log.
Arguments
| :: (MonadBaseControl IO m, MonadIO m, Integral a) | |
| => ByteString | host |
| -> Int | port |
| -> a | beginning time stamp in microseconds |
| -> [RestoreOption] | option flags |
| -> MonarchT m () |
Set the replication master.
status :: (MonadBaseControl IO m, MonadIO m) => MonarchT m ByteStringSource
Get the status string of the database.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => ByteString | function name |
| -> [MiscOption] | option flags |
| -> [ByteString] | arguments |
| -> MonarchT m [ByteString] |
Call a versatile function for miscellaneous operations.