class Redis::TransactionApi

Overview

API for sending commands in a transaction.

Used in Redis#multi.

Example:

redis.multi do |multi|
  multi.set("foo1", "first")
  multi.set("foo2", "second")
end

In this example, the multi object passed to the block is a TransactionApi object.

Included Modules

Defined in:

redis/transaction_api.cr

Constructors

Instance Method Summary

Instance methods inherited from module Redis::CommandExecution::FutureOriented

array_or_nil_command(request : Request) : Redis::Future array_or_nil_command, integer_array_command(request : Request) : Redis::Future integer_array_command, integer_command(request : Request) : Redis::Future integer_command, integer_or_nil_command(request : Request) : Redis::Future integer_or_nil_command, string_array_command(request : Request) : Redis::Future string_array_command, string_array_or_integer_command(request : Request) : Redis::Future string_array_or_integer_command, string_array_or_string_command(request : Request) : Redis::Future string_array_or_string_command, string_array_or_string_or_nil_command(request : Request) : Redis::Future string_array_or_string_or_nil_command, string_command(request : Request) : Redis::Future string_command, string_or_nil_command(request : Request) : Redis::Future string_or_nil_command, void_command(request : Request) : Redis::Future void_command

Instance methods inherited from module Redis::Commands

append(key, value) append, auth(password) auth, bitcount(key, from = nil, to = nil) bitcount, bitop(operation, key, keys : Array(String)) : Int64
bitop(operation, key, *keys : String) : Int64
bitop
, bitpos(key, bit, start = nil, to = nil) bitpos, blpop(keys, timeout_in_seconds) blpop, brpop(keys, timeout_in_seconds) brpop, brpoplpush(source, destination, timeout_in_seconds = nil) brpoplpush, decr(key) decr, decrby(key, decrement) decrby, del(keys : Array)
del(*keys)
del
, dump(key) dump, echo(message) echo, eval(script : String, keys = [] of RedisValue, args = [] of RedisValue) eval, evalsha(sha1, keys = [] of RedisValue, args = [] of RedisValue) evalsha, exists(key) exists, expire(key, seconds) expire, expireat(key, unix_date) expireat, flushall flushall, flushdb flushdb, geoadd(key, longitude, latitude, place) geoadd, geodist(key, member1, member2, unit = nil) geodist, geohash(key, *args) geohash, geopos(key, *args) geopos, georadius(key, longitude, latitude, radius, unit, withcoord = nil, withdist = nil, withhash = nil, count = nil, sort = nil) georadius, georadiusbymember(key, member, radius, unit, withcoord = nil, withdist = nil, withhash = nil, count = nil, sort = nil) georadiusbymember, get(key) get, getbit(key, index) getbit, getrange(key, start_index, end_index) getrange, getset(key, value) getset, hdel(key, field) hdel, hexists(key, field) hexists, hget(key, field) hget, hgetall(key) hgetall, hincrby(key, field, increment) hincrby, hincrbyfloat(key, field, increment) hincrbyfloat, hkeys(key) hkeys, hlen(key) hlen, hmget(key, fields : Array(String)) : Array(RedisValue)
hmget(key, *fields : String) : Array(RedisValue)
hmget
, hmset(key, hash) hmset, hscan(key, cursor, match = nil, count = nil) hscan, hset(key, field, value) hset, hsetnx(key, field, value) hsetnx, hvals(key) hvals, incr(key) incr, incrby(key, increment) incrby, incrbyfloat(key, increment) incrbyfloat, info(section : String | Nil = nil) info, keys(pattern) keys, lindex(key, index) lindex, linsert(key, where, pivot, value) linsert, llen(key) llen, lpop(key) lpop, lpush(key, values : Array(RedisValue))
lpush(key, *values)
lpush
, lpushx(key, value) lpushx, lrange(key, from, to) lrange, lrem(key, count, value) lrem, lset(key, index, value) lset, ltrim(key, start, stop) ltrim, mget(keys : Array(String)) : Array(RedisValue)
mget(*keys)
mget
, mset(hash : Hash) mset, msetnx(hash) msetnx, object_encoding(key) object_encoding, object_idletime(key) object_idletime, object_refcount(key) object_refcount, persist(key) persist, pexpire(key, milis) pexpire, pexpireat(key, unix_date_in_millis) pexpireat, pfadd(key, values : Array(String)) : Int64
pfadd(key, *values : String) : Int64
pfadd
, pfcount(keys : Array(String)) : Int64
pfcount(*keys : String) : Int64
pfcount
, pfmerge(keys : Array(String))
pfmerge(*keys : String)
pfmerge
, ping ping, psetex(key, expire_in_milis, value) psetex, psubscribe(*channel_patterns, &callback_setup_block : Subscription -> )
psubscribe(channel_patterns : Array(String))
psubscribe(*channel_patterns)
psubscribe
, pttl(key) pttl, publish(channel, message) publish, punsubscribe(channel_patterns : Array(String))
punsubscribe(*channel_patterns)
punsubscribe
, quit quit, randomkey randomkey, rename(old_key, new_key) rename, renamenx(old_key, new_key) renamenx, restore(key, ttl_in_milis : Int, serialized_value : String, replace = false) restore, rpop(key) rpop, rpoplpush(source, destination) rpoplpush, rpush(key, values : Array(RedisValue))
rpush(key, *values : String)
rpush
, rpushx(key, value) rpushx, sadd(key, values : Array(RedisValue))
sadd(key, *values)
sadd
, scan(cursor, match = nil, count = nil) scan, scard(key) scard, script_exists(sha1_array : Array(Reference)) script_exists, script_flush script_flush, script_kill script_kill, script_load(script : String) script_load, sdiff(keys : Array(String)) : Array(RedisValue)
sdiff(*keys : String) : Array(RedisValue)
sdiff
, sdiffstore(destination, keys : Array(String)) : Int64
sdiffstore(destination, *keys : String) : Int64
sdiffstore
, select(database_number) select, set(key, value, ex = nil, px = nil, nx = nil, xx = nil) set, setbit(key, index, value) setbit, setex(key, expire_in_seconds, value) setex, setnx(key, value) setnx, setrange(key, start_index, value) setrange, sinter(keys : Array(String)) : Array(RedisValue)
sinter(*keys : String) : Array(RedisValue)
sinter
, sinterstore(destination_key, keys : Array(String)) : Int64
sinterstore(destination_key, *keys : String) : Int64
sinterstore
, sismember(key, value) sismember, smembers(key) smembers, smove(source, destination, member) smove, sort(key, by = nil, limit = nil, get : Array(RedisValue) | Nil = nil, order = "ASC", alpha = false, store = nil) sort, spop(key, count = nil) spop, srandmember(key, count = nil) srandmember, srem(key, values : Array(RedisValue))
srem(key, *values)
srem
, sscan(key, cursor, match = nil, count = nil) sscan, strlen(key) strlen, subscribe(*channels, &callback_setup_block : Subscription -> )
subscribe(channels : Array(String)) : Void
subscribe(*channels : String)
subscribe
, sunion(keys : Array(String))
sunion(*keys : String)
sunion
, sunionstore(destination, keys : Array(String)) : Int64
sunionstore(destination, *keys : String) : Int64
sunionstore
, ttl(key) ttl, type(key) type, unsubscribe(channels : Array(String)) : Nil
unsubscribe(*channels)
unsubscribe
, unwatch unwatch, watch(keys : Array(String))
watch(*keys)
watch
, zadd(key, scores_and_members : Array(RedisValue))
zadd(key, *scores_and_members)
zadd
, zcard(key) zcard, zcount(key, min, max) zcount, zincrby(key, increment, member) zincrby, zinterstore(destination, keys : Array, weights = nil, aggregate = nil) zinterstore, zlexcount(key, min, max) zlexcount, zrange(key, start, stop, with_scores = false) zrange, zrangebylex(key, min, max, limit = nil) zrangebylex, zrangebyscore(key, min, max, limit = nil, with_scores = false) zrangebyscore, zrank(key, member) zrank, zrem(key, member) zrem, zremrangebylex(key, min, max) zremrangebylex, zremrangebyrank(key, start, stop) zremrangebyrank, zremrangebyscore(key, start, stop) zremrangebyscore, zrevrange(key, start, stop, with_scores = false) zrevrange, zrevrangebylex(key, min, max, limit = nil) zrevrangebylex, zrevrangebyscore(key, min, max, limit = nil, with_scores = false) zrevrangebyscore, zrevrank(key, member) zrevrank, zscan(key, cursor, match = nil, count = nil) zscan, zscore(key, member) zscore, zunionstore(destination, keys : Array, weights = nil, aggregate = nil) zunionstore

Constructor Detail

def self.new(strategy : Redis::Strategy::Transaction, namespace : String = "") #

[View source]

Instance Method Detail

def discard #

Aborts the current transaction.

Example:

redis.multi do |multi|
  multi.set("foo", "the new value")
  multi.discard
end

[View source]