Name : perl-AsciiDB-TagFile
| |
Version : 1.06
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 5.2
| Date : 2015-06-11 04:54:44
|
Group : Development/Libraries/Perl
| Source RPM : perl-AsciiDB-TagFile-1.06-5.2.src.rpm
|
Size : 0.02 MB
| |
Packager : (none)
| |
Summary : Tie class for a simple ASCII database
|
Description :
The *AsciiDB::TagFile* provides a hash-table-like interface to a simple ASCII database.
The ASCII database stores each record in into a file:
$directory/recordKey1$sufix $directory/recordKey2$sufix ... $directory/recordKeyI< N>$sufix
And a record has this format:
[fieldName1]: value1 [fieldName2]: value2 ... [fieldNameI< N>]: value2
After you\'ve tied the hash you can access this database as access a hash of hashes:
$hash{recordKey1}{fieldName1} = ...
To bind the %hash to the class AsciiDB::TagFile you have to use the tie function:
tie %hash, \'AsciiDB::TagFile\', PARAM1 => $param1, ...;
The parameters are:
* DIRECTORY
The directory where the records will be stored or readed from. The default value is the current directory.
* SUFIX
The records are stored as files. The file name of a record is the key plus this sufix (if supplied).
For example, if the record with key \'josear\' and sufix \'.record\', will be stored into file: \'josear.record\'.
If this parameter is not supplied the records won\'t have a sufix.
* LOCK
If you set this parameter to 1 TagFile will perform basic locking. Record files will be share locked before reading them, and exclusive locked when syncing (writing) them.
This basic locking only guarantees that a record file is always written correctly, but as TagFile keep records in memory you can still suffer consistency problems reading fields.
The default value is 0, i.e. the database won\'t be locked.
* READONLY
If you set this parameter to 1 the database will be read only and all changes will be discarted.
The default value is 0, i.e. the database can be changed.
* CACHESIZE
Records loaded from disk (or simply created) are keeped in memory till the tied hash is deleted. You can limit the number of records in memory setting this option to a value ($cacheSize).
All records are purged from memory if their count reach $cacheSize.
You can purge the records manually using the purge() method.
Of course, the $caseSize should be a positive number, and you can use the 0 value to turn off the caching (useful when testing).
The default value for CACHESIZE is \'infinite\' (more or less...)
* FILEMODE
Filemode assigned to new created files.
If this parameter is not supplied the new created files will have the default permissions.
* SCHEMA
This parameter is a hash reference that contains the database definition.
With ORDER you can specify in which order fields will be saved into the file.
For example,
SCHEMA => { ORDER => [ \'fieldHi\', \'field2There\', \'fieldWorld\' ] }
will save the record this way:
[fieldHi]: ... [fieldThere]: ... [fieldWorld]: ...
NOTE: this parameter is MANDATORY, and you have to specify all the fields. *If you forget to list a field it will not be saved*.
With KEY,ENCODE and KEY,DECODE you can define an special encoding for keys when used as filenames.
For example, if using this SCHEMA:
SCHEMA => { ORDER => [\'a\', \'b\', \'c\'], KEY => { ENCODE => sub { $_[0] =~ s{/}{_SLASH_}g; $_[0] }, DECODE => sub { $_[0] =~ s{_SLASH_}{/}g; $_[0] }, } }
a record with the key \'s1/s2\' will be saved into filename \'s1_SLASH_s2\'. The DECODE subroutine is used to traslate back to the original key.
NOTE: You should use this feature if you allow filesystem metacharacters (as \'/\', used in Unix to split path components) in your keys.
The data will be saved to disk when the hash is destroyed (and garbage collected by perl), so if you need for safety to write the updated data you can call the *sync* method to do it.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-A/openSUSE_Tumbleweed/noarch |