ElasticSearchX::Sequence::Iterator - Fast integer ID sequences with ElasticSearch
version 0.01
my $it = $seq->sequence('mail_id'); say $it->next; # 1 $mail_id->set(1000); say $it->next # 1000
ElasticSearchX::Sequence::Iterators are returned by ElasticSearchX::Sequence, which is the "controller class". An Iterator is a "named sequence" and the IDs it returns will be unique.
Iterator
my $it = ElasticSearchX::Sequence::Iterator->new( sequence => $seq, # ElasticSearchX::Sequence instance, required name => 'mail_id', # name of iterator, required size => 100, # number of IDs to reserve at a time, default 100 );
new() returns a new instance of ElasticSearchX::Sequence::Iterator.
new()
Normally, you would never need to call this method directly, but instead you would use "sequence()" in ElasticSearchX::Sequence.
IDs are reserved in blocks of size (default 100).
size
$id = $it->next;
Returns the next ID in the sequence.
$id = $it->release($id);
Returns $id to allow it to be reused.
$id
NOTE: You must be certain that the ID hasn't already been used by your application. Also, there is no guarantee that your released ID will be reused. It is "released" only to the current iterator - this is not application wide.
$it->set($new_id)
This can be used to set a new HIGHER ID for this iterator. You cannot reset the iterator to a lower number without deleting the index.
$name = $it->name()
Read-only getter for the iterator name.
$seq = $it->sequence();
Read-only getter for the associated ElasticSearchX::Sequence instance.
ElasticSearchX::Sequence, ElasticSearch, http://www.elasticsearch.org
Clinton Gormley <drtech@cpan.org>
This software is copyright (c) 2011 by Clinton Gormley.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install ElasticSearchX::Sequence, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ElasticSearchX::Sequence
CPAN shell
perl -MCPAN -e shell install ElasticSearchX::Sequence
For more information on module installation, please visit the detailed CPAN module installation guide.