DR-Tarantool
view release on metacpan or search on metacpan
lib/DR/Tarantool.pm view on Meta::CPAN
=head3 Update
$tnt->update(users => 123 => [[ role => set => 'not_admin' ]]);
It is possible to modify any field in a tuple. A field can be
accessed by field name or number. A set of modifications can be
provided in a Perl array.
The following update operations are supported:
=over
=item set
Assign a field
=item add, and, or, xor
Arithmetic and bitwise operations for integers.
=item substr
Replace a substring with a paste (similar to Perl splice).
=item insert
Insert a field before the given field.
=item delete
Delete a field.
=item push
Append a field at the tail of the tuple.
=item pop
Pop a field from the tail of the tuple.
=back
=head3 Lua
$tnt->call_lua(my_proc_name => [ arguments, ...]);
Invoke a Lua stored procedure by name.
=head2 Supported data types
The driver supports all Tarantool types (B<NUM>, B<NUM64>, B<STR>),
as well as some client-only types, which are converted to the
above server types automatically on the client:
=over
=item UTF8STR
A unicode string.
=item MONEY
Fixed decimal currency. Stores the value on the server in B<NUM> type,
by multiplying the given amount by 100. The largest amount
that can be stored in this type is, therefore, around 20 000 000.
Can store negative values.
=item BIGMONEY
The same as above, but uses B<NUM64> as the underlying storage.
=item JSON
An arbitrary Perl object is automatically serialized to JSON with
L<JSON::XS> on insertion, and deserialized on selection.
=back
The basic data transfer unit in Tarantool protocol is a single
tuple. A selected tuple is automatically wrapped into an instance
of class L<DR::Tarantool::Tuple>. An object of this class can be
used as an associative container, in which any field can be
accessed by field name:
my $user = $tnt->select(users => 123);
printf("user: %s, role: %s\n", $user->name, $user->role);
To run driver tests, the following Perl modules are also necessary:
L<AnyEvent>, L<Coro>, L<Test::Pod>, L<Test::Spelling>,
L<Devel::GlobalDestruction>, L<JSON::XS>.
To run tests, do:
perl Makefile.PL
make
make test
The test suite attempts to find the server and start it, thus
make sure L<tarantool_box> is available in the path, or export
TARANTOOL_BOX=/path/to/tarantool_box.
=cut
use 5.008008;
use strict;
use warnings;
use Carp;
$Carp::Internal{ (__PACKAGE__) }++;
use base qw(Exporter);
our %EXPORT_TAGS = (
client => [ qw( tarantool async_tarantool coro_tarantool) ],
constant => [
qw(
TNT_INSERT TNT_SELECT TNT_UPDATE TNT_DELETE TNT_CALL TNT_PING
( run in 1.109 second using v1.01-cache-2.11-cpan-39bf76dae61 )