db::File - flat-file storage back end
This module implements a flat-file storage back end. Flat files will generally:
Be faster for insertion and retrieval;
Be slower for lookups (searching), and for verifications.
Flat files simply lack the indexing and features of relational databases. However, for simple operations, overhead is avoided. This module has a dummy method deletebyinterval(), so that offloading records is not supported.
Internally, the following files are used:
A data file, identified by the configuration variable db. The value must be in the format file:name. The name part is taken relative to the home of the HammerServer (or absolute if it starts with a slash).
An index file, used for fast lookups. The name is name.idx
A lock file, named name.lock
Internally, the module uses 3 files, based on the specified name (following the prefix file: of the configuration variable db):
The bare name itself: a flat file of line-separated records. Each record (one line) has tab-separated fields, which are: a sequence id, timestamp, hash, previous id, signature, data. Newlines in each field are represented as \n; any backspace is represented as \\. (This is of course to make sure that data with newlines doesn't break the file parsing.)
An index file, named name.idx: An index, consisting of file offsets into the datafile. Each line states one offset; the first one pointing to the record with id 1, the second one pointing to the record with id 2, and so on. The offset strings are integers over 19 positions, terminated by a newline. Therefore, the offset of record R can be found in the index file at file offset (R-1)*20.
A lock file, named name.lock. Method new() establishes an
flock() on this file, method DESTROY() releases it. This advisory
lock prevents concurrency issues.
The tamper-resistant server, all used modules, and the documentation were written by Karel Kubat / karel@e-tunity.com. Copyright (c) 2009 ff. Distributed under GPLV3.