DR::Tarantool::Spaces - spaces container
use DR::Tarantool::Spaces; my $s = new DR::Tarantool::Spaces({ 1 => { name => 'users', # space name default_type => 'STR', # undescribed fields fields => [ qw(login password role), { name => 'counter', type => 'NUM' }, { name => 'something', type => 'UTF8STR', }, { name => 'opts', type => 'JSON', } ], indexes => { 0 => 'login', 1 => [ qw(login password) ], 2 => { name => 'my_idx', fields => 'login', }, 3 => { name => 'my_idx2', fields => [ 'counter', 'something' ] } } }, 0 => { ... } }); my $f = $s->pack_field('users', 'counter', 10); my $f = $s->pack_field('users', 3, 10); # the same my $f = $s->pack_field(1, 3, 10); # the same my $ts = $s->pack_keys([1,2,3] => 'my_idx'); my $t = $s->pack_primary_key([1,2,3]);
The package describes all spaces that You use. It supports the following field types:
- standard tarantool types.
- the same as STR, but string will be utf8-decoded after extracting from database.
- the same as NUM and NUM64, but contain signed values.
- the filed will be encoded by JSON::XS before inserting and decoded after extracting from database.
my $spaces = DR::Tarantool::Spaces->new( $spaces );
Returns space object by number or name.
my $space = $spaces->space('name'); my $space = $spaces->space(0);
Returns space number by its name.
packs one field before making database request
my $field = $spaces->pack_field('space', 'field', $data);
unpacks one field after extracting data from database
my $field = $spaces->unpack_field('space', 'field', $data);
packs tuple before making database request
my $t = $spaces->pack_tuple('space', [ 1, 2, 3 ]);
unpacks tuple after extracting data from database
my $t = $spaces->unpack_tuple('space', \@fields);
constructor
use DR::Tarantool::Spaces; my $space = DR::Tarantool::Space->new($no, $space);
Creates (or returns) class for storage tuples. The class will be child of DR::Tarantool::Tuple. Returns unique class (package) name. If package is already exists, the method won't recreate it.
returns space name
returns space number
Returns number of field by its name.
Returns index of the first element that is not described in the space.
packs field before making database request
unpacks field after extracting data from database
returns index number by its name.
returns index name by its number.
Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org> Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru> This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License.
The project is placed git repo on github: https://github.com/unera/dr-tarantool/.
To install DR::Tarantool, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DR::Tarantool
CPAN shell
perl -MCPAN -e shell install DR::Tarantool
For more information on module installation, please visit the detailed CPAN module installation guide.