Skip to content

keitwb/DBIx--Class--Allocator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

DBIx::Class::Allocator - DBIx::Class component for allocating blocks of auto-incremented columns

SYNOPSIS

In your DBIC ResultSet package for a particular model:
  
  __PACKAGE__->load_components(qw/
      Allocator
  /);
  __PACKAGE__->allocated_column('table_id'); # Assuming there is an autoincrement 
                                             # column named 'table_id'

Then, with your ResultSet instance:

  my ($first_id, $last_id) = $resultset->allocate_ids(10); # Allocates 10 ids

DESCRIPTION

A DBIx::Class component that gives ResultSets the ability to allocate blocks of auto-increment ids from the database. This is useful for creating id pools that an application can reserve and use without having to be connected (through a web interface) to the database (e.g. mobile apps that might not always have network connectivity).

DBMS support

The following RDBMS systems are currently supported: - PostgreSQL - SQLite

For SQLite, the call to allocated_column is unnecessary. SQLite stores the autoincrement sequences on a table level (in the sqlite_sequence table), so the column it is used with is irrelevant.

EXPORT

None by default.

SEE ALSO

AUTHOR

Ben Keith, <keitwb@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2012 by Ben Keith

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.

About

A ResultSet component for DBIx::Class that allocates id blocks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages