| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.Redis.Schema.Lock
Synopsis
- data LockParams = LockParams {}
- data ShareableLockParams = ShareableLockParams {}
- defaultMetaParams :: LockParams
- data ExclusiveLock
- withExclusiveLock :: (MonadCatch m, MonadThrow m, MonadMask m, MonadIO m, Ref ref, ValueType ref ~ ExclusiveLock) => Pool (RefInstance ref) -> LockParams -> ref -> m a -> m a
- data ShareableLock
- withShareableLock :: (MonadCatch m, MonadThrow m, MonadMask m, MonadIO m, Ref ref, ValueType ref ~ ShareableLock, SimpleValue (RefInstance ref) (MetaLock ref)) => Pool (RefInstance ref) -> ShareableLockParams -> LockSharing -> ref -> m a -> m a
- data LockSharing
Documentation
data LockParams Source #
Constructors
| LockParams | |
Fields | |
data ShareableLockParams Source #
Constructors
| ShareableLockParams | |
Fields | |
data ExclusiveLock Source #
Redis value representing the exclusive lock.
Instances
Arguments
| :: (MonadCatch m, MonadThrow m, MonadMask m, MonadIO m, Ref ref, ValueType ref ~ ExclusiveLock) | |
| => Pool (RefInstance ref) | |
| -> LockParams | Params of the lock, such as timeouts or TTL. |
| -> ref | Lock ref |
| -> m a | The action to perform under lock |
| -> m a |
Execute the given action in an exclusively locked context.
This is useful mainly for operations that need to be atomic while manipulating *both* Redis and database (such as various commit scripts).
- For Redis-only transactions, use
atomically. - For database-only transactions, use database transactions.
- For shareable locks, use
withShareableLock. - For exclusive locks,
withExclusiveLockis more efficient.
data ShareableLock Source #
Instances
Arguments
| :: (MonadCatch m, MonadThrow m, MonadMask m, MonadIO m, Ref ref, ValueType ref ~ ShareableLock, SimpleValue (RefInstance ref) (MetaLock ref)) | |
| => Pool (RefInstance ref) | |
| -> ShareableLockParams | Params of the lock, such as timeouts or TTL. |
| -> LockSharing | Shared / Exclusive |
| -> ref | Lock ref |
| -> m a | The action to perform under lock |
| -> m a |
Execute the given action in a locked, possibly shared context.
This is useful mainly for operations that need to be atomic while manipulating *both* Redis and database (such as various commit scripts).
- For Redis-only transactions, use
atomically. - For database-only transactions, use database transactions.
- For exclusive locks, withExclusiveLock is more efficient.
NOTE: the shareable lock seems to have quite a lot of performance overhead. Always benchmark first whether the exclusive lock would perform better in your scenario, even when a shareable lock would be sufficient in theory.
data LockSharing Source #