valkyrie/pipeline

Types

pub opaque type Pipeline

Values

pub fn append(
  pipeline: Pipeline,
  key: String,
  value: String,
) -> Pipeline

Adds APPEND to the pipeline. See valkyrie.append for more details.

pub fn decr(pipeline: Pipeline, key: String) -> Pipeline

Adds DECR to the pipeline. See valkyrie.decr for more details.

pub fn decrby(
  pipeline: Pipeline,
  key: String,
  value: Int,
) -> Pipeline

Adds DECRBY to the pipeline. See valkyrie.decrby for more details.

pub fn del(pipeline: Pipeline, keys: List(String)) -> Pipeline

Adds DEL to the pipeline. See valkyrie.del for more details.

pub fn exec(
  pipeline: Pipeline,
  conn: valkyrie.Connection,
  timeout: Int,
) -> Result(List(resp.Value), valkyrie.Error)

Execute all commands in the pipeline and return the results.

Returns a list of resp.Value for each command in the order they were added. Returns Ok([]) immediately if the pipeline is empty.

pub fn exec_transaction(
  pipeline: Pipeline,
  conn: valkyrie.Connection,
  timeout: Int,
) -> Result(List(resp.Value), valkyrie.Error)

Execute commands in the pipeline in a Redis transaction with MULTI and EXEC.

Returns a list of resp.Value for each command in the order they were added. Returns Ok([]) immediately if the pipeline is empty.

pub fn exists(pipeline: Pipeline, keys: List(String)) -> Pipeline

Adds EXISTS to the pipeline. See valkyrie.exists for more details.

pub fn expire(
  pipeline: Pipeline,
  key: String,
  ttl: Int,
  condition: option.Option(valkyrie.ExpireCondition),
) -> Pipeline

Adds EXPIRE to the pipeline. See valkyrie.expire for more details.

pub fn expireat(
  pipeline: Pipeline,
  key: String,
  unix_seconds: Int,
  condition: option.Option(valkyrie.ExpireCondition),
) -> Pipeline

Adds EXPIREAT to the pipeline. See valkyrie.expireat for more details.

pub fn expiretime(pipeline: Pipeline, key: String) -> Pipeline

Adds EXPIRETIME to the pipeline. See valkyrie.expiretime for more details.

pub fn get(pipeline: Pipeline, key: String) -> Pipeline

Adds GET to the pipeline. See valkyrie.get for more details.

pub fn has_errors(results: List(resp.Value)) -> Bool

Check if any results from a pipeline or transaction contain errors.

This is useful for quickly determining if any commands failed without inspecting each result individually.

Example

let assert Ok(results) = pipeline.exec(p, conn, 1000)
case pipeline.has_errors(results) {
  True -> io.println("Some commands failed")
  False -> io.println("All commands succeeded")
}
pub fn hdel(
  pipeline: Pipeline,
  key: String,
  fields: List(String),
) -> Pipeline

Adds HDEL to the pipeline. See valkyrie.hdel for more details.

pub fn hexists(
  pipeline: Pipeline,
  key: String,
  field: String,
) -> Pipeline

Adds HEXISTS to the pipeline. See valkyrie.hexists for more details.

pub fn hget(
  pipeline: Pipeline,
  key: String,
  field: String,
) -> Pipeline

Adds HGET to the pipeline. See valkyrie.hget for more details.

pub fn hgetall(pipeline: Pipeline, key: String) -> Pipeline

Adds HGETALL to the pipeline. See valkyrie.hgetall for more details.

pub fn hincrby(
  pipeline: Pipeline,
  key: String,
  field: String,
  value: Int,
) -> Pipeline

Adds HINCRBY to the pipeline. See valkyrie.hincrby for more details.

pub fn hincrbyfloat(
  pipeline: Pipeline,
  key: String,
  field: String,
  value: Float,
) -> Pipeline

Adds HINCRBYFLOAT to the pipeline. See valkyrie.hincrbyfloat for more details.

pub fn hkeys(pipeline: Pipeline, key: String) -> Pipeline

Adds HKEYS to the pipeline. See valkyrie.hkeys for more details.

pub fn hlen(pipeline: Pipeline, key: String) -> Pipeline

Adds HLEN to the pipeline. See valkyrie.hlen for more details.

pub fn hmget(
  pipeline: Pipeline,
  key: String,
  fields: List(String),
) -> Pipeline

Adds HMGET to the pipeline. See valkyrie.hmget for more details.

pub fn hscan(
  pipeline: Pipeline,
  key: String,
  cursor: Int,
  pattern_filter: option.Option(String),
  count: Int,
) -> Pipeline

Adds HSCAN to the pipeline. See valkyrie.hscan for more details.

pub fn hset(
  pipeline: Pipeline,
  key: String,
  values: dict.Dict(String, String),
) -> Pipeline

Adds HSET to the pipeline. See valkyrie.hset for more details.

pub fn hsetnx(
  pipeline: Pipeline,
  key: String,
  field: String,
  value: String,
) -> Pipeline

Adds HSETNX to the pipeline. See valkyrie.hsetnx for more details.

pub fn hstrlen(
  pipeline: Pipeline,
  key: String,
  field: String,
) -> Pipeline

Adds HSTRLEN to the pipeline. See valkyrie.hstrlen for more details.

pub fn hvals(pipeline: Pipeline, key: String) -> Pipeline

Adds HVALS to the pipeline. See valkyrie.hvals for more details.

pub fn incr(pipeline: Pipeline, key: String) -> Pipeline

Adds INCR to the pipeline. See valkyrie.incr for more details.

pub fn incrby(
  pipeline: Pipeline,
  key: String,
  value: Int,
) -> Pipeline

Adds INCRBY to the pipeline. See valkyrie.incrby for more details.

pub fn incrbyfloat(
  pipeline: Pipeline,
  key: String,
  value: Float,
) -> Pipeline

Adds INCRBYFLOAT to the pipeline. See valkyrie.incrbyfloat for more details.

pub fn key_type(pipeline: Pipeline, key: String) -> Pipeline

Adds TYPE to the pipeline. See valkyrie.key_type for more details.

pub fn keys(pipeline: Pipeline, pattern: String) -> Pipeline

Adds KEYS to the pipeline. See valkyrie.keys for more details.

pub fn lindex(
  pipeline: Pipeline,
  key: String,
  index: Int,
) -> Pipeline

Adds LINDEX to the pipeline. See valkyrie.lindex for more details.

pub fn linsert(
  pipeline: Pipeline,
  key: String,
  position: valkyrie.InsertPosition,
  pivot: String,
  value: String,
) -> Pipeline

Adds LINSERT to the pipeline. See valkyrie.linsert for more details.

pub fn llen(pipeline: Pipeline, key: String) -> Pipeline

Adds LLEN to the pipeline. See valkyrie.llen for more details.

pub fn lpop(
  pipeline: Pipeline,
  key: String,
  count: Int,
) -> Pipeline

Adds LPOP to the pipeline. See valkyrie.lpop for more details.

pub fn lpush(
  pipeline: Pipeline,
  key: String,
  values: List(String),
) -> Pipeline

Adds LPUSH to the pipeline. See valkyrie.lpush for more details.

pub fn lpushx(
  pipeline: Pipeline,
  key: String,
  values: List(String),
) -> Pipeline

Adds LPUSHX to the pipeline. See valkyrie.lpushx for more details.

pub fn lrange(
  pipeline: Pipeline,
  key: String,
  start: Int,
  end: Int,
) -> Pipeline

Adds LRANGE to the pipeline. See valkyrie.lrange for more details.

pub fn lrem(
  pipeline: Pipeline,
  key: String,
  count: Int,
  value: String,
) -> Pipeline

Adds LREM to the pipeline. See valkyrie.lrem for more details.

pub fn lset(
  pipeline: Pipeline,
  key: String,
  index: Int,
  value: String,
) -> Pipeline

Adds LSET to the pipeline. See valkyrie.lset for more details.

pub fn mget(pipeline: Pipeline, keys: List(String)) -> Pipeline

Adds MGET to the pipeline. See valkyrie.mget for more details.

pub fn mset(
  pipeline: Pipeline,
  kv_list: List(#(String, String)),
) -> Pipeline

Adds MSET to the pipeline. See valkyrie.mset for more details.

pub fn new() -> Pipeline

Create a new empty pipeline.

pub fn persist(pipeline: Pipeline, key: String) -> Pipeline

Adds PERSIST to the pipeline. See valkyrie.persist for more details.

pub fn pexpire(
  pipeline: Pipeline,
  key: String,
  ttl: Int,
  condition: option.Option(valkyrie.ExpireCondition),
) -> Pipeline

Adds PEXPIRE to the pipeline. See valkyrie.pexpire for more details.

pub fn pexpiretime(pipeline: Pipeline, key: String) -> Pipeline

Adds PEXPIRETIME to the pipeline. See valkyrie.pexpiretime for more details.

pub fn ping(
  pipeline: Pipeline,
  message: option.Option(String),
) -> Pipeline

Adds PING to the pipeline. See valkyrie.ping for more details.

pub fn randomkey(pipeline: Pipeline) -> Pipeline

Adds RANDOMKEY to the pipeline. See valkyrie.randomkey for more details.

pub fn rename(
  pipeline: Pipeline,
  key: String,
  new_key: String,
) -> Pipeline

Adds RENAME to the pipeline. See valkyrie.rename for more details.

pub fn renamenx(
  pipeline: Pipeline,
  key: String,
  new_key: String,
) -> Pipeline

Adds RENAMENX to the pipeline. See valkyrie.renamenx for more details.

pub fn rpop(
  pipeline: Pipeline,
  key: String,
  count: Int,
) -> Pipeline

Adds RPOP to the pipeline. See valkyrie.rpop for more details.

pub fn rpush(
  pipeline: Pipeline,
  key: String,
  values: List(String),
) -> Pipeline

Adds RPUSH to the pipeline. See valkyrie.rpush for more details.

pub fn rpushx(
  pipeline: Pipeline,
  key: String,
  values: List(String),
) -> Pipeline

Adds RPUSHX to the pipeline. See valkyrie.rpushx for more details.

pub fn sadd(
  pipeline: Pipeline,
  key: String,
  values: List(String),
) -> Pipeline

Adds SADD to the pipeline. See valkyrie.sadd for more details.

pub fn scan(
  pipeline: Pipeline,
  cursor: Int,
  pattern_filter: option.Option(String),
  count: Int,
  key_type_filter: option.Option(valkyrie.KeyType),
) -> Pipeline

Adds SCAN to the pipeline. See valkyrie.scan for more details.

pub fn scard(pipeline: Pipeline, key: String) -> Pipeline

Adds SCARD to the pipeline. See valkyrie.scard for more details.

pub fn set(
  pipeline: Pipeline,
  key: String,
  value: String,
  options: option.Option(valkyrie.SetOptions),
) -> Pipeline

Adds SET to the pipeline. See valkyrie.set for more details.

pub fn sismember(
  pipeline: Pipeline,
  key: String,
  value: String,
) -> Pipeline

Adds SISMEMBER to the pipeline. See valkyrie.sismember for more details.

pub fn smembers(pipeline: Pipeline, key: String) -> Pipeline

Adds SMEMBERS to the pipeline. See valkyrie.smembers for more details.

pub fn sscan(
  pipeline: Pipeline,
  key: String,
  cursor: Int,
  pattern_filter: option.Option(String),
  count: Int,
) -> Pipeline

Adds SSCAN to the pipeline. See valkyrie.sscan for more details.

pub fn to_results(
  results: List(resp.Value),
) -> List(Result(resp.Value, String))

Convert a list of pipeline results to a list of Results, turning SimpleError and BulkError values into Error variants.

This makes it easier to work with pipeline results using standard Result functions like result.try, list.all, or result.partition.

Example

let assert Ok(results) = pipeline.exec(p, conn, 1000)
let #(successes, failures) =
  results
  |> pipeline.to_results
  |> result.partition
pub fn zadd(
  pipeline: Pipeline,
  key: String,
  members: List(#(String, valkyrie.Score)),
  condition: valkyrie.ZAddCondition,
  return_changed: Bool,
) -> Pipeline

Adds ZADD to the pipeline. See valkyrie.zadd for more details.

pub fn zcard(pipeline: Pipeline, key: String) -> Pipeline

Adds ZCARD to the pipeline. See valkyrie.zcard for more details.

pub fn zcount(
  pipeline: Pipeline,
  key: String,
  min: valkyrie.Score,
  max: valkyrie.Score,
) -> Pipeline

Adds ZCOUNT to the pipeline. See valkyrie.zcount for more details.

pub fn zincrby(
  pipeline: Pipeline,
  key: String,
  member: String,
  delta: valkyrie.Score,
) -> Pipeline

Adds ZINCRBY to the pipeline. See valkyrie.zincrby for more details.

pub fn zpopmax(
  pipeline: Pipeline,
  key: String,
  count: Int,
) -> Pipeline

Adds ZPOPMAX to the pipeline. See valkyrie.zpopmax for more details.

pub fn zpopmin(
  pipeline: Pipeline,
  key: String,
  count: Int,
) -> Pipeline

Adds ZPOPMIN to the pipeline. See valkyrie.zpopmin for more details.

pub fn zrandmember(
  pipeline: Pipeline,
  key: String,
  count: Int,
) -> Pipeline

Adds ZRANDMEMBER to the pipeline. See valkyrie.zrandmember for more details.

pub fn zrange(
  pipeline: Pipeline,
  key: String,
  start: valkyrie.NumericBound(Int),
  stop: valkyrie.NumericBound(Int),
  reverse: Bool,
) -> Pipeline

Adds ZRANGE to the pipeline. See valkyrie.zrange for more details.

pub fn zrange_bylex(
  pipeline: Pipeline,
  key: String,
  start: valkyrie.LexBound,
  stop: valkyrie.LexBound,
  reverse: Bool,
) -> Pipeline

Adds ZRANGE BYLEX to the pipeline. See valkyrie.zrange_bylex for more details.

pub fn zrange_byscore(
  pipeline: Pipeline,
  key: String,
  start: valkyrie.NumericBound(valkyrie.Score),
  stop: valkyrie.NumericBound(valkyrie.Score),
  reverse: Bool,
) -> Pipeline

Adds ZRANGE BYSCORE to the pipeline. See valkyrie.zrange_byscore for more details.

pub fn zrank(
  pipeline: Pipeline,
  key: String,
  member: String,
) -> Pipeline

Adds ZRANK to the pipeline. See valkyrie.zrank for more details.

pub fn zrank_withscore(
  pipeline: Pipeline,
  key: String,
  member: String,
) -> Pipeline

Adds ZRANK WITHSCORE to the pipeline. See valkyrie.zrank_withscore for more details.

pub fn zrem(
  pipeline: Pipeline,
  key: String,
  members: List(String),
) -> Pipeline

Adds ZREM to the pipeline. See valkyrie.zrem for more details.

pub fn zrevrank(
  pipeline: Pipeline,
  key: String,
  member: String,
) -> Pipeline

Adds ZREVRANK to the pipeline. See valkyrie.zrevrank for more details.

pub fn zrevrank_withscore(
  pipeline: Pipeline,
  key: String,
  member: String,
) -> Pipeline

Adds ZREVRANK WITHSCORE to the pipeline. See valkyrie.zrevrank_withscore for more details.

pub fn zscan(
  pipeline: Pipeline,
  key: String,
  cursor: Int,
  pattern_filter: option.Option(String),
  count: Int,
) -> Pipeline

Adds ZSCAN to the pipeline. See valkyrie.zscan for more details.

pub fn zscore(
  pipeline: Pipeline,
  key: String,
  member: String,
) -> Pipeline

Adds ZSCORE to the pipeline. See valkyrie.zscore for more details.

Search Document