NAME
EDG::WP4::CCM::CacheManager::DB
SYNOPSIS
# Class style
my $db = EDG::WP4::CCM::CacheManager::DB->new($prefix, %opts);
# Write the hashref to the database file
$db->write($hashref);
# Open the database and tie to hashref
$db->open($hashref);
# Direct read access to database (combines new and open)
$success = EDG::WP4::CCM::CacheManager::DB::read($hashref, $prefix);
DESCRIPTION
This is a wrapper around all access to the profile database format, which copes with multiple possible data formats.
Methods
-
new / _initialize
Create a new DB instance using
prefix, the filename without extension (will be used by both the.dbfile itself and a.fmtformat description).Optional parameters
-
log
A Reporter instance for logging/reporting.
-
-
test_supported_format
Test if
dbformatis a supported format.Returns SUCCESS on success, undef on failure (and sets
failattribute). -
write
Given a hashref
hashref, write out the hash in a database formatdbformat. (Ifdbformatis not defined, the default formatDB_Filewill be used).Once successfully written, the
hashrefwill be untied and does not remain connected to the persistent storage.permsis an optional hashref with the file permissions for both database file and format description (owner/mode/group, FileWriter style).Returns undef on success, a string with error message otherwise.
-
open
Open the database file.
The format of the database file will be determined by reading the format file. If that file does not exist, then default format
DB_Filewill be used.Returns undef on success, a string with error message otherwise.
On success, the
hashrefwill be tied to the specified database.
Functions
-
read_db
Given
hashrefandprefix, create a new instance usingprefix(and any other options) and return theopened database with hashref.read_dbfunction is exported -
read
An alias for read_db (not exported, kept for legacy).