hlrdb-core-0.2.0.0: High-level Redis Database Core API
Safe HaskellNone
LanguageHaskell2010

HLRDB.Structures.SSet

Description

SortedSets, like lists, support automatic cardinality management when provided a TrimScheme. HLRDB exports a more opinionated and less easy-to-make-mistakes API than Redis supports. Scores are golf-(or race) style, where lower numbers are better. The API is setup to make retrieving the best items and discarding the worst items natural, rather than trying to remember which direction the data is sorted in.

You should ensure that your Haskell Eq instances respect the equality induced by your encoding scheme, i.e., that a == b ~ encode a == encode b.

Synopsis

Documentation

zadd :: (MonadRedis m, Traversable t) => RedisSSet a b -> a -> t (Double, b) -> m (ActionPerformed Creation) Source #

Add items and scores

zscore :: MonadRedis m => RedisSSet a b -> a -> b -> m (Maybe Double) Source #

Lookup an element's score

zupdate :: MonadRedis m => RedisSSet a b -> a -> (Double -> Double) -> m () Source #

Read the scores from Redis, apply the given trasformation, and write the resulting data

zbest :: MonadRedis m => RedisSSet a b -> a -> Integer -> Integer -> m [b] Source #

Retrieve the given range of best-performing elements. Range is inclusive, just as with Haskell's [ 1 .. 5 ] notation, and it is 0-based, which means [ 0 .. 4 ] is what corresponds to the English phrase "Best 5."

zworst :: MonadRedis m => RedisSSet a b -> a -> Integer -> Integer -> m [b] Source #

Retrieve the given range of worst-performing elements. Range is inclusive, just as with Haskell's [ 1 .. 5 ] notation, and it is 0-based, which means [ 0 .. 4 ] is what corresponds to the English phrase "Worst 5."

zmember :: MonadRedis m => RedisSSet a b -> a -> b -> m Bool Source #

Test if an object is a member of the set.

zrank :: MonadRedis m => RedisSSet a b -> a -> b -> m (Maybe Integer) Source #

Calculate the rank of an item. The best item has rank 0.

zrevrank :: MonadRedis m => RedisSSet a b -> a -> b -> m (Maybe Integer) Source #

Calculate the rank of an item starting from the end, e.g., the worst item has rank 0.

zrem :: (MonadRedis m, Traversable t) => RedisSSet a b -> a -> t b -> m (ActionPerformed Deletion) Source #

Remove items from a sorted set

zincrby :: MonadRedis m => RedisSSet a b -> a -> (Integer, b) -> m Double Source #

Increment an item's score. If the item does not already exist, it is inserted with the given score.

zcard :: MonadRedis m => RedisSSet a b -> a -> m Integer Source #

The cardinality of a sorted set

zscan :: MonadRedis m => RedisSSet a b -> a -> Cursor -> m (Maybe Cursor, [(b, Double)]) Source #

Use a cursor to iterate a collection.

zrangebyscore :: MonadRedis m => RedisSSet a b -> a -> Maybe Double -> Maybe Double -> Maybe Integer -> Maybe Integer -> m [(b, Double)] Source #

Retrieve items in a score range; final parameters are min, max, offset, and limit