Class::PObject::Driver::DBM - Base class for DBM-related pobject drivers
use Class::PObject::Driver::DBM; @ISA = ('Class::PObject::Driver::DBM'); sub dbh { my ($self, $pobject_name, $properties) = @_; ... }
Class::PObject::Driver::DBM is a base class for all the DBM-related pobject drivers. Class::PObject::Driver::DBM is a direct subclass of Class::PObject::Driver.
Class::PObject::Driver::DBM is a direct subclass of Class::PObject::Driver, and provides all the necessary methods common for DBM-related disk access.
Refer to Class::PObject::Driver for the details of all the driver-specific methods. Class::PObject::Driver::DBM overrides save(), load() and remove() methods with the versions relevant to DBM-related disk access.
save()
load()
remove()
dbh($self, $pobject_name, \%properties, $lock_type) - called whenever base methods need database tied hash. DBM drivers should provide this method, which should return an array of elements, namely $DB - an DBM object, usually returned from tie() or tied() functions; $dbh - a hash tied to database; $unlock - an action required for unlocking the database. $unlock should be a reference to a subroutine, which when called should release the lock.
dbh($self, $pobject_name, \%properties, $lock_type)
$DB
tie()
tied()
$dbh
$unlock
Currently base methods ignore $DB, but it may change in the future.
_filename($self, $pobject_name, \%properties) - returns a name of the file to connect to. It first looks for $properties-{datasource}> and if it exists, uses the value as a directory name object file should be created in. If it's missing, defaults to systems temporary folder.
_filename($self, $pobject_name, \%properties)
$properties-
It then returns a file name derived out of $pobject_name inside this directory.
$pobject_name
_lock($file, $filename, $lock_type) - acquires either shared or exclusive lock depending on the $lock_type, which can be either of w or r.
_lock($file, $filename, $lock_type)
$lock_type
Returns a reference to an action (subroutine), which perform unlocking for this particular lock. On failure returns undef. _lock() is usually called from within dbh(), and return value is returned together with database handles.
_lock()
dbh()
Currently the only record index is the id column. By introducing configurable indexes, object selections (through load() method) can be improved tremendously. Syntax similar to the following may suffice:
pobject Article => { columns => ['id', 'title', 'author', 'content'], indexes => ['title', 'author'], driver => 'db_file', datasource => './data' }
This issue is to be addressed in subsequent releases.
Class::PObject::Driver, Class::PObject::Driver::DB_File Class::PObject::Driver::DBI
For author and copyright information refer to Class::PObject's online manual.
To install Class::PObject, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::PObject
CPAN shell
perl -MCPAN -e shell install Class::PObject
For more information on module installation, please visit the detailed CPAN module installation guide.