Redis::Transaction - utilities for handling transactions of Redis
use Redis; use Redis::Transaction qw/multi_exec watch_multi_exec/; # atomically increment foo and bar. It will execute following commands typically. # > MULTI # > INCR foo # > INCR bar # > EXEC multi_exec Redis->new, 10, sub { my $redis = shift; $redis->incr('foo'); $redis->incr('bar'); }; # atomically increment the value of a key by 1 (let's suppose Redis doesn't have INCR). # It will execute following commands typically. # > WATCH mykey # > GET mykey # > MULTI # > SET mykey, 1 # > EXEC watch_multi_exec Redis->new, ['mykey'], 10, sub { my $redis = shift; return $redis->get('mykey'); }, sub { my ($redis, $value) = @_; $redis->set('mykey', $value + 1); };
Redis::Transaction is utilities for handling transactions of Redis.
multi_exec($redis:Redis, $retry_count:Int, $code:Code)
Queue commands and execute them atomically.
watch_multi_exec($redis:Redis, $watch_keys:ArrayRef, $retry_count:Int, $watch_code:Code, $exec_code:Code)
Queue commands and execute them atomically. watch_multi_exec will retry $watch_code and $exec_code if $watch_keys are changed by another client.
watch_multi_exec
$watch_code
$exec_code
$watch_keys
Redis.pm
Redis::Fast
Description of Transactions
Copyright (C) Ichinose Shogo.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Ichinose Shogo <shogo82148@gmail.com>
To install Redis::Transaction, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Redis::Transaction
CPAN shell
perl -MCPAN -e shell install Redis::Transaction
For more information on module installation, please visit the detailed CPAN module installation guide.