/usr/share/doc/libghc-hedis-doc/html/hedis.txt is in libghc-hedis-doc 0.9.12-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | -- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Client library for the Redis datastore: supports full command set,
-- pipelining.
--
-- Redis is an open source, advanced key-value store. It is often
-- referred to as a data structure server since keys can contain strings,
-- hashes, lists, sets and sorted sets. This library is a Haskell client
-- for the Redis datastore. Compared to other Haskell client libraries it
-- has some advantages:
--
-- <ul>
-- <li><i>Compatibility with Latest Stable Redis:</i> Hedis is intended
-- to be used with the latest stable version of Redis (currently 3.2).
-- Most redis commands (<a>http://redis.io/commands</a>) are available as
-- haskell functions, although MONITOR and SYNC are intentionally
-- omitted. Additionally, a low-level API is exposed that makes it easy
-- for the library user to implement further commands, such as new
-- commands from an experimental Redis version.</li>
-- <li><i>Automatic Optimal Pipelining:</i> Commands are pipelined
-- (<a>http://redis.io/topics/pipelining</a>) as much as possible without
-- any work by the user. See
-- <a>http://informatikr.com/2012/redis-pipelining.html</a> for a
-- technical explanation of automatic optimal pipelining.</li>
-- <li><i>Enforced Pub/Sub semantics:</i> When subscribed to the Redis
-- Pub/Sub server (<a>http://redis.io/topics/pubsub</a>), clients are not
-- allowed to issue commands other than subscribing to or unsubscribing
-- from channels. This library uses the type system to enforce the
-- correct behavior.</li>
-- <li><i>Connect via TCP or Unix Domain Socket:</i> TCP sockets are the
-- default way to connect to a Redis server. For connections to a server
-- on the same machine, Unix domain sockets offer higher performance than
-- the standard TCP connection.</li>
-- </ul>
--
-- For detailed documentation, see the <a>Database.Redis</a> module.
@package hedis
@version 0.9.12
module Database.Redis
-- | Context for normal command execution, outside of transactions. Use
-- <a>runRedis</a> to run actions of this type.
--
-- In this context, each result is wrapped in an <a>Either</a> to account
-- for the possibility of Redis returning an <a>Error</a> reply.
data Redis a
-- | Interact with a Redis datastore specified by the given
-- <a>Connection</a>.
--
-- Each call of <a>runRedis</a> takes a network connection from the
-- <a>Connection</a> pool and runs the given <a>Redis</a> action. Calls
-- to <a>runRedis</a> may thus block while all connections from the pool
-- are in use.
runRedis :: Connection -> Redis a -> IO a
-- | Deconstruct Redis constructor.
--
-- <a>unRedis</a> and <a>reRedis</a> can be used to define instances for
-- arbitrary typeclasses.
--
-- WARNING! These functions are considered internal and no guarantee is
-- given at this point that they will not break in future.
unRedis :: Redis a -> ReaderT RedisEnv IO a
-- | Reconstruct Redis constructor.
reRedis :: ReaderT RedisEnv IO a -> Redis a
-- | This class captures the following behaviour: In a context <tt>m</tt>,
-- a command will return its result wrapped in a "container" of type
-- <tt>f</tt>.
--
-- Please refer to the Command Type Signatures section of this page for
-- more information.
class (MonadRedis m) => RedisCtx m f | m -> f
returnDecode :: (RedisCtx m f, RedisResult a) => Reply -> m (f a)
class (Monad m) => MonadRedis m
liftRedis :: MonadRedis m => Redis a -> m a
-- | A threadsafe pool of network connections to a Redis server. Use the
-- <a>connect</a> function to create one.
data Connection
-- | Constructs a <a>Connection</a> pool to a Redis server designated by
-- the given <a>ConnectInfo</a>. The first connection is not actually
-- established until the first call to the server.
connect :: ConnectInfo -> IO Connection
-- | Constructs a <a>Connection</a> pool to a Redis server designated by
-- the given <a>ConnectInfo</a>, then tests if the server is actually
-- there. Throws an exception if the connection to the Redis server can't
-- be established.
checkedConnect :: ConnectInfo -> IO Connection
-- | Information for connnecting to a Redis server.
--
-- It is recommended to not use the <a>ConnInfo</a> data constructor
-- directly. Instead use <a>defaultConnectInfo</a> and update it with
-- record syntax. For example to connect to a password protected Redis
-- server running on localhost and listening to the default port:
--
-- <pre>
-- myConnectInfo :: ConnectInfo
-- myConnectInfo = defaultConnectInfo {connectAuth = Just "secret"}
-- </pre>
data ConnectInfo
ConnInfo :: HostName -> PortID -> Maybe ByteString -> Integer -> Int -> NominalDiffTime -> Maybe NominalDiffTime -> ConnectInfo
[connectHost] :: ConnectInfo -> HostName
[connectPort] :: ConnectInfo -> PortID
-- | When the server is protected by a password, set <a>connectAuth</a> to
-- <a>Just</a> the password. Each connection will then authenticate by
-- the <a>auth</a> command.
[connectAuth] :: ConnectInfo -> Maybe ByteString
-- | Each connection will <a>select</a> the database with the given index.
[connectDatabase] :: ConnectInfo -> Integer
-- | Maximum number of connections to keep open. The smallest acceptable
-- value is 1.
[connectMaxConnections] :: ConnectInfo -> Int
-- | Amount of time for which an unused connection is kept open. The
-- smallest acceptable value is 0.5 seconds. If the <tt>timeout</tt>
-- value in your redis.conf file is non-zero, it should be larger than
-- <a>connectMaxIdleTime</a>.
[connectMaxIdleTime] :: ConnectInfo -> NominalDiffTime
-- | Optional timeout until connection to Redis gets established.
-- <tt>ConnectTimeoutException</tt> gets thrown if no socket get
-- connected in this interval of time.
[connectTimeout] :: ConnectInfo -> Maybe NominalDiffTime
-- | Default information for connecting:
--
-- <pre>
-- connectHost = "localhost"
-- connectPort = PortNumber 6379 -- Redis default port
-- connectAuth = Nothing -- No password
-- connectDatabase = 0 -- SELECT database 0
-- connectMaxConnections = 50 -- Up to 50 connections
-- connectMaxIdleTime = 30 -- Keep open for 30 seconds
-- </pre>
defaultConnectInfo :: ConnectInfo
-- | Either a host name e.g., <tt>"haskell.org"</tt> or a numeric host
-- address string consisting of a dotted decimal IPv4 address or an IPv6
-- address e.g., <tt>"192.168.0.1"</tt>.
type HostName = String
data PortID :: *
Service :: String -> PortID
PortNumber :: PortNumber -> PortID
UnixSocket :: String -> PortID
auth :: ByteString -> Redis (Either Reply Status)
echo :: (RedisCtx m f) => ByteString -> m (f ByteString)
ping :: (RedisCtx m f) => m (f Status)
quit :: (RedisCtx m f) => m (f Status)
select :: RedisCtx m f => Integer -> m (f Status)
del :: (RedisCtx m f) => [ByteString] -> m (f Integer)
dump :: (RedisCtx m f) => ByteString -> m (f ByteString)
exists :: (RedisCtx m f) => ByteString -> m (f Bool)
expire :: (RedisCtx m f) => ByteString -> Integer -> m (f Bool)
expireat :: (RedisCtx m f) => ByteString -> Integer -> m (f Bool)
keys :: (RedisCtx m f) => ByteString -> m (f [ByteString])
-- | Options for the <a>migrate</a> command.
data MigrateOpts
MigrateOpts :: Bool -> Bool -> MigrateOpts
[migrateCopy] :: MigrateOpts -> Bool
[migrateReplace] :: MigrateOpts -> Bool
-- | Redis default <a>MigrateOpts</a>. Equivalent to omitting all optional
-- parameters.
--
-- <pre>
-- MigrateOpts
-- { migrateCopy = False -- remove the key from the local instance
-- , migrateReplace = False -- don't replace existing key on the remote instance
-- }
-- </pre>
defaultMigrateOpts :: MigrateOpts
migrate :: (RedisCtx m f) => ByteString -> ByteString -> ByteString -> Integer -> Integer -> m (f Status)
migrateMultiple :: (RedisCtx m f) => ByteString -> ByteString -> Integer -> Integer -> MigrateOpts -> [ByteString] -> m (f Status)
move :: (RedisCtx m f) => ByteString -> Integer -> m (f Bool)
objectRefcount :: (RedisCtx m f) => ByteString -> m (f Integer)
objectEncoding :: (RedisCtx m f) => ByteString -> m (f ByteString)
objectIdletime :: (RedisCtx m f) => ByteString -> m (f Integer)
persist :: (RedisCtx m f) => ByteString -> m (f Bool)
pexpire :: (RedisCtx m f) => ByteString -> Integer -> m (f Bool)
pexpireat :: (RedisCtx m f) => ByteString -> Integer -> m (f Bool)
pttl :: (RedisCtx m f) => ByteString -> m (f Integer)
randomkey :: (RedisCtx m f) => m (f (Maybe ByteString))
rename :: (RedisCtx m f) => ByteString -> ByteString -> m (f Status)
renamenx :: (RedisCtx m f) => ByteString -> ByteString -> m (f Bool)
restore :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Status)
restoreReplace :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Status)
data Cursor
cursor0 :: Cursor
data ScanOpts
ScanOpts :: Maybe ByteString -> Maybe Integer -> ScanOpts
[scanMatch] :: ScanOpts -> Maybe ByteString
[scanCount] :: ScanOpts -> Maybe Integer
-- | Redis default <a>ScanOpts</a>. Equivalent to omitting all optional
-- parameters.
--
-- <pre>
-- ScanOpts
-- { scanMatch = Nothing -- don't match any pattern
-- , scanCount = Nothing -- don't set any requirements on number elements returned (works like value <tt>COUNT 10</tt>)
-- }
-- </pre>
defaultScanOpts :: ScanOpts
scan :: (RedisCtx m f) => Cursor -> m (f (Cursor, [ByteString]))
scanOpts :: (RedisCtx m f) => Cursor -> ScanOpts -> m (f (Cursor, [ByteString]))
-- | Options for the <a>sort</a> command.
data SortOpts
SortOpts :: Maybe ByteString -> (Integer, Integer) -> [ByteString] -> SortOrder -> Bool -> SortOpts
[sortBy] :: SortOpts -> Maybe ByteString
[sortLimit] :: SortOpts -> (Integer, Integer)
[sortGet] :: SortOpts -> [ByteString]
[sortOrder] :: SortOpts -> SortOrder
[sortAlpha] :: SortOpts -> Bool
-- | Redis default <a>SortOpts</a>. Equivalent to omitting all optional
-- parameters.
--
-- <pre>
-- SortOpts
-- { sortBy = Nothing -- omit the BY option
-- , sortLimit = (0,-1) -- return entire collection
-- , sortGet = [] -- omit the GET option
-- , sortOrder = Asc -- sort in ascending order
-- , sortAlpha = False -- sort numerically, not lexicographically
-- }
-- </pre>
defaultSortOpts :: SortOpts
data SortOrder
Asc :: SortOrder
Desc :: SortOrder
sort :: (RedisCtx m f) => ByteString -> SortOpts -> m (f [ByteString])
sortStore :: (RedisCtx m f) => ByteString -> ByteString -> SortOpts -> m (f Integer)
ttl :: (RedisCtx m f) => ByteString -> m (f Integer)
data RedisType
None :: RedisType
String :: RedisType
Hash :: RedisType
List :: RedisType
Set :: RedisType
ZSet :: RedisType
getType :: (RedisCtx m f) => ByteString -> m (f RedisType)
wait :: (RedisCtx m f) => Integer -> Integer -> m (f Integer)
hdel :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
hexists :: (RedisCtx m f) => ByteString -> ByteString -> m (f Bool)
hget :: (RedisCtx m f) => ByteString -> ByteString -> m (f (Maybe ByteString))
hgetall :: (RedisCtx m f) => ByteString -> m (f [(ByteString, ByteString)])
hincrby :: (RedisCtx m f) => ByteString -> ByteString -> Integer -> m (f Integer)
hincrbyfloat :: (RedisCtx m f) => ByteString -> ByteString -> Double -> m (f Double)
hkeys :: (RedisCtx m f) => ByteString -> m (f [ByteString])
hlen :: (RedisCtx m f) => ByteString -> m (f Integer)
hmget :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f [Maybe ByteString])
hmset :: (RedisCtx m f) => ByteString -> [(ByteString, ByteString)] -> m (f Status)
hscan :: (RedisCtx m f) => ByteString -> Cursor -> m (f (Cursor, [(ByteString, ByteString)]))
hscanOpts :: (RedisCtx m f) => ByteString -> Cursor -> ScanOpts -> m (f (Cursor, [(ByteString, ByteString)]))
hset :: (RedisCtx m f) => ByteString -> ByteString -> ByteString -> m (f Bool)
hsetnx :: (RedisCtx m f) => ByteString -> ByteString -> ByteString -> m (f Bool)
hstrlen :: (RedisCtx m f) => ByteString -> ByteString -> m (f Integer)
hvals :: (RedisCtx m f) => ByteString -> m (f [ByteString])
pfadd :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
pfcount :: (RedisCtx m f) => [ByteString] -> m (f Integer)
pfmerge :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f ByteString)
blpop :: (RedisCtx m f) => [ByteString] -> Integer -> m (f (Maybe (ByteString, ByteString)))
brpop :: (RedisCtx m f) => [ByteString] -> Integer -> m (f (Maybe (ByteString, ByteString)))
brpoplpush :: (RedisCtx m f) => ByteString -> ByteString -> Integer -> m (f (Maybe ByteString))
lindex :: (RedisCtx m f) => ByteString -> Integer -> m (f (Maybe ByteString))
linsertBefore :: (RedisCtx m f) => ByteString -> ByteString -> ByteString -> m (f Integer)
linsertAfter :: (RedisCtx m f) => ByteString -> ByteString -> ByteString -> m (f Integer)
llen :: (RedisCtx m f) => ByteString -> m (f Integer)
lpop :: (RedisCtx m f) => ByteString -> m (f (Maybe ByteString))
lpush :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
lpushx :: (RedisCtx m f) => ByteString -> ByteString -> m (f Integer)
lrange :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f [ByteString])
lrem :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Integer)
lset :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Status)
ltrim :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f Status)
rpop :: (RedisCtx m f) => ByteString -> m (f (Maybe ByteString))
rpoplpush :: (RedisCtx m f) => ByteString -> ByteString -> m (f (Maybe ByteString))
rpush :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
rpushx :: (RedisCtx m f) => ByteString -> ByteString -> m (f Integer)
eval :: (RedisCtx m f, RedisResult a) => ByteString -> [ByteString] -> [ByteString] -> m (f a)
evalsha :: (RedisCtx m f, RedisResult a) => ByteString -> [ByteString] -> [ByteString] -> m (f a)
data DebugMode
scriptDebug :: (RedisCtx m f) => DebugMode -> m (f Bool)
scriptExists :: (RedisCtx m f) => [ByteString] -> m (f [Bool])
scriptFlush :: (RedisCtx m f) => m (f Status)
scriptKill :: (RedisCtx m f) => m (f Status)
scriptLoad :: (RedisCtx m f) => ByteString -> m (f ByteString)
bgrewriteaof :: (RedisCtx m f) => m (f Status)
bgsave :: (RedisCtx m f) => m (f Status)
clientGetname :: (RedisCtx m f) => m (f Status)
clientList :: (RedisCtx m f) => m (f [ByteString])
clientPause :: (RedisCtx m f) => Integer -> m (f Status)
data ReplyMode
clientReply :: (RedisCtx m f) => ReplyMode -> m (f Bool)
clientSetname :: (RedisCtx m f) => ByteString -> m (f ByteString)
commandCount :: (RedisCtx m f) => m (f Integer)
commandInfo :: (RedisCtx m f) => [ByteString] -> m (f [ByteString])
configGet :: (RedisCtx m f) => ByteString -> m (f [(ByteString, ByteString)])
configResetstat :: (RedisCtx m f) => m (f Status)
configRewrite :: (RedisCtx m f) => m (f Status)
configSet :: (RedisCtx m f) => ByteString -> ByteString -> m (f Status)
dbsize :: (RedisCtx m f) => m (f Integer)
debugObject :: (RedisCtx m f) => ByteString -> m (f ByteString)
flushall :: (RedisCtx m f) => m (f Status)
flushdb :: (RedisCtx m f) => m (f Status)
info :: (RedisCtx m f) => m (f ByteString)
infoSection :: (RedisCtx m f) => ByteString -> m (f ByteString)
lastsave :: (RedisCtx m f) => m (f Integer)
save :: (RedisCtx m f) => m (f Status)
slaveof :: (RedisCtx m f) => ByteString -> ByteString -> m (f Status)
-- | A single entry from the slowlog.
data Slowlog
Slowlog :: Integer -> Integer -> Integer -> [ByteString] -> Slowlog
-- | A unique progressive identifier for every slow log entry.
[slowlogId] :: Slowlog -> Integer
-- | The unix timestamp at which the logged command was processed.
[slowlogTimestamp] :: Slowlog -> Integer
-- | The amount of time needed for its execution, in microseconds.
[slowlogMicros] :: Slowlog -> Integer
-- | The command and it's arguments.
[slowlogCmd] :: Slowlog -> [ByteString]
slowlogGet :: (RedisCtx m f) => Integer -> m (f [Slowlog])
slowlogLen :: (RedisCtx m f) => m (f Integer)
slowlogReset :: (RedisCtx m f) => m (f Status)
time :: (RedisCtx m f) => m (f (Integer, Integer))
sadd :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
scard :: (RedisCtx m f) => ByteString -> m (f Integer)
sdiff :: (RedisCtx m f) => [ByteString] -> m (f [ByteString])
sdiffstore :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
sinter :: (RedisCtx m f) => [ByteString] -> m (f [ByteString])
sinterstore :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
sismember :: (RedisCtx m f) => ByteString -> ByteString -> m (f Bool)
smembers :: (RedisCtx m f) => ByteString -> m (f [ByteString])
smove :: (RedisCtx m f) => ByteString -> ByteString -> ByteString -> m (f Bool)
spop :: (RedisCtx m f) => ByteString -> m (f (Maybe ByteString))
srandmember :: (RedisCtx m f) => ByteString -> m (f (Maybe ByteString))
srandmemberN :: (RedisCtx m f) => ByteString -> Integer -> m (f (Maybe ByteString))
srem :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
sscan :: (RedisCtx m f) => ByteString -> Cursor -> m (f (Cursor, [ByteString]))
sscanOpts :: (RedisCtx m f) => ByteString -> Cursor -> ScanOpts -> m (f (Cursor, [ByteString]))
sunion :: (RedisCtx m f) => [ByteString] -> m (f [ByteString])
sunionstore :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
data ZaddOpts
ZaddOpts :: Maybe Condition -> Bool -> Bool -> ZaddOpts
[zaddCondition] :: ZaddOpts -> Maybe Condition
[zaddChange] :: ZaddOpts -> Bool
[zaddIncrement] :: ZaddOpts -> Bool
-- | Redis default <a>ZaddOpts</a>. Equivalent to omitting all optional
-- parameters.
--
-- <pre>
-- ZaddOpts
-- { zaddCondition = Nothing -- omit NX and XX options
-- , zaddChange = False -- don't modify the return value from the number of new elements added, to the total number of elements changed
-- , zaddIncrement = False -- don't add like ZINCRBY
-- }
-- </pre>
defaultZaddOpts :: ZaddOpts
zadd :: (RedisCtx m f) => ByteString -> [(Double, ByteString)] -> m (f Integer)
zaddOpts :: (RedisCtx m f) => ByteString -> [(Double, ByteString)] -> ZaddOpts -> m (f Integer)
zcard :: (RedisCtx m f) => ByteString -> m (f Integer)
zcount :: (RedisCtx m f) => ByteString -> Double -> Double -> m (f Integer)
zincrby :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Double)
data Aggregate
Sum :: Aggregate
Min :: Aggregate
Max :: Aggregate
zinterstore :: (RedisCtx m f) => ByteString -> [ByteString] -> Aggregate -> m (f Integer)
zinterstoreWeights :: (RedisCtx m f) => ByteString -> [(ByteString, Double)] -> Aggregate -> m (f Integer)
zlexcount :: (RedisCtx m f) => ByteString -> ByteString -> ByteString -> m (f Integer)
zrange :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f [ByteString])
zrangeWithscores :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f [(ByteString, Double)])
data RangeLex a
Incl :: a -> RangeLex a
Excl :: a -> RangeLex a
Minr :: RangeLex a
Maxr :: RangeLex a
zrangebylex :: (RedisCtx m f) => ByteString -> RangeLex ByteString -> RangeLex ByteString -> m (f [ByteString])
zrangebylexLimit :: (RedisCtx m f) => ByteString -> RangeLex ByteString -> RangeLex ByteString -> Integer -> Integer -> m (f [ByteString])
zrangebyscore :: (RedisCtx m f) => ByteString -> Double -> Double -> m (f [ByteString])
zrangebyscoreWithscores :: (RedisCtx m f) => ByteString -> Double -> Double -> m (f [(ByteString, Double)])
zrangebyscoreLimit :: (RedisCtx m f) => ByteString -> Double -> Double -> Integer -> Integer -> m (f [ByteString])
zrangebyscoreWithscoresLimit :: (RedisCtx m f) => ByteString -> Double -> Double -> Integer -> Integer -> m (f [(ByteString, Double)])
zrank :: (RedisCtx m f) => ByteString -> ByteString -> m (f (Maybe Integer))
zrem :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
zremrangebylex :: (RedisCtx m f) => ByteString -> ByteString -> ByteString -> m (f Integer)
zremrangebyrank :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f Integer)
zremrangebyscore :: (RedisCtx m f) => ByteString -> Double -> Double -> m (f Integer)
zrevrange :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f [ByteString])
zrevrangeWithscores :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f [(ByteString, Double)])
zrevrangebyscore :: (RedisCtx m f) => ByteString -> Double -> Double -> m (f [ByteString])
zrevrangebyscoreWithscores :: (RedisCtx m f) => ByteString -> Double -> Double -> m (f [(ByteString, Double)])
zrevrangebyscoreLimit :: (RedisCtx m f) => ByteString -> Double -> Double -> Integer -> Integer -> m (f [ByteString])
zrevrangebyscoreWithscoresLimit :: (RedisCtx m f) => ByteString -> Double -> Double -> Integer -> Integer -> m (f [(ByteString, Double)])
zrevrank :: (RedisCtx m f) => ByteString -> ByteString -> m (f (Maybe Integer))
zscan :: (RedisCtx m f) => ByteString -> Cursor -> m (f (Cursor, [(ByteString, Double)]))
zscanOpts :: (RedisCtx m f) => ByteString -> Cursor -> ScanOpts -> m (f (Cursor, [(ByteString, Double)]))
zscore :: (RedisCtx m f) => ByteString -> ByteString -> m (f (Maybe Double))
zunionstore :: (RedisCtx m f) => ByteString -> [ByteString] -> Aggregate -> m (f Integer)
zunionstoreWeights :: (RedisCtx m f) => ByteString -> [(ByteString, Double)] -> Aggregate -> m (f Integer)
append :: (RedisCtx m f) => ByteString -> ByteString -> m (f Integer)
bitcount :: (RedisCtx m f) => ByteString -> m (f Integer)
bitcountRange :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f Integer)
bitopAnd :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
bitopOr :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
bitopXor :: (RedisCtx m f) => ByteString -> [ByteString] -> m (f Integer)
bitopNot :: (RedisCtx m f) => ByteString -> ByteString -> m (f Integer)
bitpos :: (RedisCtx m f) => ByteString -> Integer -> Integer -> Integer -> m (f Integer)
decr :: (RedisCtx m f) => ByteString -> m (f Integer)
decrby :: (RedisCtx m f) => ByteString -> Integer -> m (f Integer)
get :: (RedisCtx m f) => ByteString -> m (f (Maybe ByteString))
getbit :: (RedisCtx m f) => ByteString -> Integer -> m (f Integer)
getrange :: (RedisCtx m f) => ByteString -> Integer -> Integer -> m (f ByteString)
getset :: (RedisCtx m f) => ByteString -> ByteString -> m (f (Maybe ByteString))
incr :: (RedisCtx m f) => ByteString -> m (f Integer)
incrby :: (RedisCtx m f) => ByteString -> Integer -> m (f Integer)
incrbyfloat :: (RedisCtx m f) => ByteString -> Double -> m (f Double)
mget :: (RedisCtx m f) => [ByteString] -> m (f [Maybe ByteString])
mset :: (RedisCtx m f) => [(ByteString, ByteString)] -> m (f Status)
msetnx :: (RedisCtx m f) => [(ByteString, ByteString)] -> m (f Bool)
psetex :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Status)
data Condition
Nx :: Condition
Xx :: Condition
data SetOpts
SetOpts :: Maybe Integer -> Maybe Integer -> Maybe Condition -> SetOpts
[setSeconds] :: SetOpts -> Maybe Integer
[setMilliseconds] :: SetOpts -> Maybe Integer
[setCondition] :: SetOpts -> Maybe Condition
set :: (RedisCtx m f) => ByteString -> ByteString -> m (f Status)
setOpts :: (RedisCtx m f) => ByteString -> ByteString -> SetOpts -> m (f Status)
setbit :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Integer)
setex :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Status)
setnx :: (RedisCtx m f) => ByteString -> ByteString -> m (f Bool)
setrange :: (RedisCtx m f) => ByteString -> Integer -> ByteString -> m (f Integer)
strlen :: (RedisCtx m f) => ByteString -> m (f Integer)
-- | Watch the given keys to determine execution of the MULTI/EXEC block
-- (<a>http://redis.io/commands/watch</a>).
watch :: [ByteString] -> Redis (Either Reply Status)
-- | Forget about all watched keys
-- (<a>http://redis.io/commands/unwatch</a>).
unwatch :: Redis (Either Reply Status)
-- | Run commands inside a transaction. For documentation on the semantics
-- of Redis transaction see <a>http://redis.io/topics/transactions</a>.
--
-- Inside the transaction block, command functions return their result
-- wrapped in a <a>Queued</a>. The <a>Queued</a> result is a proxy object
-- for the actual command's result, which will only be available after
-- <tt>EXEC</tt>ing the transaction.
--
-- Example usage (note how <a>Queued</a> 's <a>Applicative</a> instance
-- is used to combine the two individual results):
--
-- <pre>
-- runRedis conn $ do
-- set "hello" "hello"
-- set "world" "world"
-- helloworld <- <a>multiExec</a> $ do
-- hello <- get "hello"
-- world <- get "world"
-- return $ (,) <$> hello <*> world
-- liftIO (print helloworld)
--
-- </pre>
multiExec :: RedisTx (Queued a) -> Redis (TxResult a)
-- | A <a>Queued</a> value represents the result of a command inside a
-- transaction. It is a proxy object for the <i>actual</i> result, which
-- will only be available after returning from a <a>multiExec</a>
-- transaction.
--
-- <a>Queued</a> values are composable by utilizing the <a>Functor</a>,
-- <a>Applicative</a> or <a>Monad</a> interfaces.
data Queued a
-- | Result of a <a>multiExec</a> transaction.
data TxResult a
-- | Transaction completed successfully. The wrapped value corresponds to
-- the <a>Queued</a> value returned from the <a>multiExec</a> argument
-- action.
TxSuccess :: a -> TxResult a
-- | Transaction aborted due to an earlier <a>watch</a> command.
TxAborted :: TxResult a
-- | At least one of the commands returned an <a>Error</a> reply.
TxError :: String -> TxResult a
-- | Command-context inside of MULTI/EXEC transactions. Use
-- <a>multiExec</a> to run actions of this type.
--
-- In the <a>RedisTx</a> context, all commands return a <a>Queued</a>
-- value. It is a proxy object for the <i>actual</i> result, which will
-- only be available after finishing the transaction.
data RedisTx a
-- | Post a message to a channel (<a>http://redis.io/commands/publish</a>).
publish :: (RedisCtx m f) => ByteString -> ByteString -> m (f Integer)
-- | Listens to published messages on subscribed channels and channels
-- matching the subscribed patterns. For documentation on the semantics
-- of Redis Pub/Sub see <a>http://redis.io/topics/pubsub</a>.
--
-- The given callback function is called for each received message.
-- Subscription changes are triggered by the returned <a>PubSub</a>. To
-- keep subscriptions unchanged, the callback can return <a>mempty</a>.
--
-- Example: Subscribe to the "news" channel indefinitely.
--
-- <pre>
-- pubSub (subscribe ["news"]) $ \msg -> do
-- putStrLn $ "Message from " ++ show (msgChannel msg)
-- return mempty
--
-- </pre>
--
-- Example: Receive a single message from the "chat" channel.
--
-- <pre>
-- pubSub (subscribe ["chat"]) $ \msg -> do
-- putStrLn $ "Message from " ++ show (msgChannel msg)
-- return $ unsubscribe ["chat"]
--
-- </pre>
--
-- It should be noted that Redis Pub/Sub by its nature is asynchronous so
-- returning <a>unsubscribe</a> does not mean that callback won't be able
-- to receive any further messages. And to guarantee that you won't won't
-- process messages after unsubscription and won't unsubscribe from the
-- same channel more than once you need to use <tt>IORef</tt> or
-- something similar
pubSub :: PubSub -> (Message -> IO PubSub) -> Redis ()
data Message
Message :: ByteString -> Message
[msgChannel, msgMessage] :: Message -> ByteString
PMessage :: ByteString -> Message
[msgPattern, msgChannel, msgMessage] :: Message -> ByteString
-- | Encapsulates subscription changes. Use <a>subscribe</a>,
-- <a>unsubscribe</a>, <a>psubscribe</a>, <a>punsubscribe</a> or
-- <a>mempty</a> to construct a value. Combine values by using the
-- <a>Monoid</a> interface, i.e. <a>mappend</a> and <a>mconcat</a>.
data PubSub
-- | Listen for messages published to the given channels
-- (<a>http://redis.io/commands/subscribe</a>).
subscribe :: [ByteString] -> PubSub
-- | Stop listening for messages posted to the given channels
-- (<a>http://redis.io/commands/unsubscribe</a>).
unsubscribe :: [ByteString] -> PubSub
-- | Listen for messages published to channels matching the given patterns
-- (<a>http://redis.io/commands/psubscribe</a>).
psubscribe :: [ByteString] -> PubSub
-- | Stop listening for messages posted to channels matching the given
-- patterns (<a>http://redis.io/commands/punsubscribe</a>).
punsubscribe :: [ByteString] -> PubSub
-- | Open a connection to the Redis server, register to all channels in the
-- <a>PubSubController</a>, and process messages and subscription change
-- requests forever. The only way this will ever exit is if there is an
-- exception from the network code or an unhandled exception in a
-- <a>MessageCallback</a> or <a>PMessageCallback</a>. For example, if the
-- network connection to Redis dies, <a>pubSubForever</a> will throw a
-- <tt>ConnectionLost</tt>. When such an exception is thrown, you can
-- recall <a>pubSubForever</a> with the same <a>PubSubController</a>
-- which will open a new connection and resubscribe to all the channels
-- which are tracked in the <a>PubSubController</a>.
--
-- The general pattern is therefore during program startup create a
-- <a>PubSubController</a> and fork a thread which calls
-- <a>pubSubForever</a> in a loop (using an exponential backoff algorithm
-- such as the <a>retry</a> package to not hammer the Redis server if it
-- does die). For example,
--
-- <pre>
-- myhandler :: ByteString -> IO ()
-- myhandler msg = putStrLn $ unpack $ decodeUtf8 msg
--
-- onInitialComplete :: IO ()
-- onInitialComplete = putStrLn "Redis acknowledged that mychannel is now subscribed"
--
-- main :: IO ()
-- main = do
-- conn <- connect defaultConnectInfo
-- pubSubCtrl <- newPubSubController [("mychannel", myhandler)] []
-- forkIO $ forever $
-- pubSubForever conn pubSubCtrl onInitialComplete
-- `catch` (\(e :: SomeException) -> do
-- putStrLn $ "Got error: " ++ show e
-- threadDelay $ 50*1000) -- TODO: use exponential backoff
--
-- {- elsewhere in your program, use pubSubCtrl to change subscriptions -}
-- </pre>
--
-- At most one active <a>pubSubForever</a> can be running against a
-- single <a>PubSubController</a> at any time. If two active calls to
-- <a>pubSubForever</a> share a single <a>PubSubController</a> there will
-- be deadlocks. If you do want to process messages using multiple
-- connections to Redis, you can create more than one
-- <a>PubSubController</a>. For example, create one PubSubController for
-- each <a>getNumCapabilities</a> and then create a Haskell thread bound
-- to each capability each calling <a>pubSubForever</a> in a loop. This
-- will create one network connection per controller/capability and allow
-- you to register separate channels and callbacks for each controller,
-- spreading the load across the capabilities.
pubSubForever :: Connection -> PubSubController -> IO () -> IO ()
-- | A Redis channel name
type RedisChannel = ByteString
-- | A Redis pattern channel name
type RedisPChannel = ByteString
-- | A handler for a message from a subscribed channel. The callback is
-- passed the message content.
--
-- Messages are processed synchronously in the receiving thread, so if
-- the callback takes a long time it will block other callbacks and other
-- messages from being received. If you need to move long-running work to
-- a different thread, we suggest you use <a>TBQueue</a> with a
-- reasonable bound, so that if messages are arriving faster than you can
-- process them, you do eventually block.
--
-- If the callback throws an exception, the exception will be thrown from
-- <a>pubSubForever</a> which will cause the entire Redis connection for
-- all subscriptions to be closed. As long as you call
-- <a>pubSubForever</a> in a loop you will reconnect to your subscribed
-- channels, but you should probably add an exception handler to each
-- callback to prevent this.
type MessageCallback = ByteString -> IO ()
-- | A handler for a message from a psubscribed channel. The callback is
-- passed the channel the message was sent on plus the message content.
--
-- Similar to <a>MessageCallback</a>, callbacks are executed
-- synchronously and any exceptions are rethrown from
-- <a>pubSubForever</a>.
type PMessageCallback = RedisChannel -> ByteString -> IO ()
-- | A controller that stores a set of channels, pattern channels, and
-- callbacks. It allows you to manage Pub/Sub subscriptions and pattern
-- subscriptions and alter them at any time throughout the life of your
-- program. You should typically create the controller at the start of
-- your program and then store it through the life of your program, using
-- <a>addChannels</a> and <a>removeChannels</a> to update the current
-- subscriptions.
data PubSubController
-- | Create a new <a>PubSubController</a>. Note that this does not
-- subscribe to any channels, it just creates the controller. The
-- subscriptions will happen once <a>pubSubForever</a> is called.
newPubSubController :: MonadIO m => [(RedisChannel, MessageCallback)] -> [(RedisPChannel, PMessageCallback)] -> m PubSubController
-- | Get the list of current channels in the <a>PubSubController</a>.
-- WARNING! This might not exactly reflect the subscribed channels in the
-- Redis server, because there is a delay between adding or removing a
-- channel in the <a>PubSubController</a> and when Redis receives and
-- processes the subscription change request.
currentChannels :: MonadIO m => PubSubController -> m [RedisChannel]
-- | Get the list of current pattern channels in the
-- <a>PubSubController</a>. WARNING! This might not exactly reflect the
-- subscribed channels in the Redis server, because there is a delay
-- between adding or removing a channel in the <a>PubSubController</a>
-- and when Redis receives and processes the subscription change request.
currentPChannels :: MonadIO m => PubSubController -> m [RedisPChannel]
-- | Add channels into the <a>PubSubController</a>, and if there is an
-- active <a>pubSubForever</a>, send the subscribe and psubscribe
-- commands to Redis. The <a>addChannels</a> function is thread-safe.
-- This function does not wait for Redis to acknowledge that the channels
-- have actually been subscribed; use <a>addChannelsAndWait</a> for that.
--
-- You can subscribe to the same channel or pattern channel multiple
-- times; the <a>PubSubController</a> keeps a list of callbacks and
-- executes each callback in response to a message.
--
-- The return value is an action <a>UnregisterCallbacksAction</a> which
-- will unregister the callbacks, which should typically used with
-- <tt>bracket</tt>.
addChannels :: MonadIO m => PubSubController -> [(RedisChannel, MessageCallback)] -> [(RedisPChannel, PMessageCallback)] -> m UnregisterCallbacksAction
-- | Call <a>addChannels</a> and then wait for Redis to acknowledge that
-- the channels are actually subscribed.
--
-- Note that this function waits for all pending subscription change
-- requests, so if you for example call <a>addChannelsAndWait</a> from
-- multiple threads simultaneously, they all will wait for all pending
-- subscription changes to be acknowledged by Redis (this is due to the
-- fact that we just track the total number of pending change requests
-- sent to Redis and just wait until that count reaches zero).
--
-- This also correctly waits if the network connection dies during the
-- subscription change. Say that the network connection dies right after
-- we send a subscription change to Redis. <a>pubSubForever</a> will
-- throw <tt>ConnectionLost</tt> and <a>addChannelsAndWait</a> will
-- continue to wait. Once you recall <a>pubSubForever</a> with the same
-- <a>PubSubController</a>, <a>pubSubForever</a> will open a new
-- connection, send subscription commands for all channels in the
-- <a>PubSubController</a> (which include the ones we are waiting for),
-- and wait for the responses from Redis. Only once we receive the
-- response from Redis that it has subscribed to all channels in
-- <a>PubSubController</a> will <a>addChannelsAndWait</a> unblock and
-- return.
addChannelsAndWait :: MonadIO m => PubSubController -> [(RedisChannel, MessageCallback)] -> [(RedisPChannel, PMessageCallback)] -> m UnregisterCallbacksAction
-- | Remove channels from the <a>PubSubController</a>, and if there is an
-- active <a>pubSubForever</a>, send the unsubscribe commands to Redis.
-- Note that as soon as this function returns, no more callbacks will be
-- executed even if more messages arrive during the period when we
-- request to unsubscribe from the channel and Redis actually processes
-- the unsubscribe request. This function is thread-safe.
--
-- If you remove all channels, the connection in <a>pubSubForever</a> to
-- redis will stay open and waiting for any new channels from a call to
-- <a>addChannels</a>. If you really want to close the connection, use
-- <a>killThread</a> or <a>cancel</a> to kill the thread running
-- <a>pubSubForever</a>.
removeChannels :: MonadIO m => PubSubController -> [RedisChannel] -> [RedisPChannel] -> m ()
-- | Call <a>removeChannels</a> and then wait for all pending subscription
-- change requests to be acknowledged by Redis. This uses the same
-- waiting logic as <a>addChannelsAndWait</a>. Since
-- <a>removeChannels</a> immediately notifies the <a>PubSubController</a>
-- to start discarding messages, you likely don't need this function and
-- can just use <a>removeChannels</a>.
removeChannelsAndWait :: MonadIO m => PubSubController -> [RedisChannel] -> [RedisPChannel] -> m ()
-- | An action that when executed will unregister the callbacks. It is
-- returned from <a>addChannels</a> or <a>addChannelsAndWait</a> and
-- typically you would use it in <tt>bracket</tt> to guarantee that you
-- unsubscribe from channels. For example, if you are using websockets to
-- distribute messages to clients, you could use something such as:
--
-- <pre>
-- websocketConn <- Network.WebSockets.acceptRequest pending
-- let mycallback msg = Network.WebSockets.sendTextData websocketConn msg
-- bracket (addChannelsAndWait ctrl [("hello", mycallback)] []) id $ const $ do
-- {- loop here calling Network.WebSockets.receiveData -}
-- </pre>
type UnregisterCallbacksAction = IO ()
-- | <a>sendRequest</a> can be used to implement commands from experimental
-- versions of Redis. An example of how to implement a command is given
-- below.
--
-- <pre>
-- -- |Redis DEBUG OBJECT command
-- debugObject :: ByteString -> <a>Redis</a> (Either <a>Reply</a> ByteString)
-- debugObject key = <a>sendRequest</a> ["DEBUG", "OBJECT", key]
-- </pre>
sendRequest :: (RedisCtx m f, RedisResult a) => [ByteString] -> m (f a)
-- | Low-level representation of replies from the Redis server.
data Reply
SingleLine :: ByteString -> Reply
Error :: ByteString -> Reply
Integer :: Integer -> Reply
Bulk :: (Maybe ByteString) -> Reply
MultiBulk :: (Maybe [Reply]) -> Reply
data Status
Ok :: Status
Pong :: Status
Status :: ByteString -> Status
class RedisResult a
decode :: RedisResult a => Reply -> Either Reply a
data ConnectionLostException
ConnectionLost :: ConnectionLostException
|