SimpleCDB

SimpleCDB - A Perl-only Constant Database.
Download

SimpleCDB Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Benjamin Low
  • Publisher web site:
  • http://search.cpan.org/~benl/SimpleCDB-1.0/SimpleCDB.pm

SimpleCDB Tags


SimpleCDB Description

SimpleCDB - A Perl-only Constant Database. SimpleCDB - A Perl-only Constant Database.SYNOPSIS use SimpleCDB; # writer # - tie blocks until DB is available (exclusive), or timeout tie %h, 'SimpleCDB', 'db', O_WRONLY or die "tie failed: $SimpleCDB::ERRORn"; $h{$k} = $v; die "store: $SimpleCDB::ERROR" if $SimpleCDB::ERROR; untie %h; # release DB (exclusive) lock # reader # - tie blocks until DB is available (shared), or timeout tie %h, 'SimpleCDB', 'db', O_RDONLY or die "tie failed: $SimpleCDB::ERRORn"; $v = $h{$i}; die "fetch: $SimpleCDB::ERROR" if $SimpleCDB::ERROR; untie %h; # release DB (shared) lockThis is a simple perl-only DB intended for constant DB applications. A constant DB is one which, once created, is only ever read from (though this implementation allows appending of new data). That is, this is an "append-only DB" - records may only be added and/or extracted.Course-grained locking provided to allow multiple users, as per flock semantics (i.e. write access requires an exclusive lock, read access needs a shared lock (see notes below re. perl < 5.004)). As (exclusive) updates may be take some time to complete, shared lock attempts will timeout after a defined waiting period (returning $! == EWOULDBLOCK). Concurrent update attempts will behave similarly, but with a longer timeout.The DB files are simple flat files, with one record per line. Records (both keys and values) may be arbitrary (binary) data. Records are extracted from these files via a plain linear search. Unsurprisingly, this search is a relatively inefficient operation. To improve extraction speed, records are randomly distributed across N files, with the average search space is reduced by 1/N compared to a single file. (See below for some example performance times.) One advantage of this flat file based solution is that the DB is human readable (assuming the data is), and with some care can be edited with a plain ol' text editor.Finally, note that this DB does not support duplicate entries. In practice, the first record found matching a given key is returned, any duplicates will be ignored. Requirements: · Perl


SimpleCDB Related Software