|
NAMEData::ObjectDriver::Driver::SimplePartition - basic partitioned object driverSYNOPSISpackage ParentObject; use base qw( Data::ObjectDriver::BaseObject ); __PACKAGE__->install_properties({ columns => [ 'parent_id', 'partition_id', ... ], ... driver => Data::ObjectDriver::Driver::DBI->new( @$GLOBAL_DB_INFO ), primary_key => 'parent_id', }); __PACKAGE__->has_partitions( number => scalar @PARTITIONS, get_driver => \&get_driver_by_partition, ); package SomeObject; use base qw( Data::ObjectDriver::BaseObject ); __PACKAGE__->install_properties({ ... driver => Data::ObjectDriver::Driver::SimplePartition->new( using => 'ParentObject' ), primary_key => ['parent_id', 'object_id'], }); DESCRIPTIONData::ObjectDriver::Driver::SimplePartition is a basic driver for objects partitioned into separate databases. See Data::ObjectDriver::Driver::Partition for more about partitioning databases.SimplePartition helps you partition objects into databases based on their association with one record of a parent class. If your classes don't meet the requirements imposed by SimplePartition, you can still write your own partitioning driver. See Data::ObjectDriver::Driver::Partition. SUGGESTED PRACTICESOften this is used for user partitioning, where the parent class is your user account class; all records of other classes that are "owned" by that user are partitioned into the same database. This allows you to scale horizontally with the number of users, at the cost of complicating querying multiple users' data together.SimplePartition will load the related instance of the parent class every time it needs to find the partition for a related object. Consider using a minimal mapping class for the parent, keeping as much data as possible in other related classes. For example, if "User" were your parent class, you might keep only the user ID and other data used to find users (such as login name and email address) in "User", keeping further profile data in another "UserProfile" class. As all the partitioned classes related to a given parent class will share the same "partition_get_driver" logic to turn a partition ID into a driver, you might put the "partition_get_driver" function in the parent class, or use a custom subclass of SimplePartition that contains and automatically specifies the "partition_get_driver" function. USAGEData::ObjectDriver::Driver::SimplePartition->new(%params)Creates a new basic partitioning driver for a particular class. The required members of %params are:
You can also include any further optional parameters you like. They will be passed to the partitioned class's "partition_get_driver" function as given. A SimplePartition driver will require these properties to be defined for partitioned classes:
DIAGNOSTICS
BUGS AND LIMITATIONSThere are no known bugs in this module.SEE ALSOData::ObjectDriver::Driver::PartitionLICENSEData::ObjectDriver is free software; you may redistribute it and/or modify it under the same terms as Perl itself.AUTHOR & COPYRIGHTExcept where otherwise noted, Data::ObjectDriver is Copyright 2005-2006 Six Apart, cpan@sixapart.com. All rights reserved.
Visit the GSP FreeBSD Man Page Interface. |