Clone this repo:
  1. 11390a4 Handle errors from Writer::close() while closing the writers by Umherirrender · 7 weeks ago master
  2. 1e936b9 build: Updating mediawiki/mediawiki-codesniffer to 51.0.0 by libraryupgrader · 10 weeks ago
  3. 3c76a3c Declare strict types on all php files by Umherirrender · 3 months ago
  4. 13c1f9c tests: Remove test case about numeric keys by Umherirrender · 3 months ago
  5. ef9b5ca build: Updating mediawiki/mediawiki-phan-config to 0.20.0 by libraryupgrader · 4 months ago

Latest Stable Version License

CDB functions for PHP

CDB, short for "constant database", refers to a very fast and highly reliable database system which uses a simple file with key value pairs. This library wraps the CDB functionality exposed in PHP via the dba_* functions. In cases where dba_* functions are not present or are not compiled with CDB support, a pure-PHP implementation is provided for falling back.

Additional documentation about the library can be found on mediawiki.org.

Usage

// Reading a CDB file
$cdb = Cdb\Reader::open( 'db.cdb' );
$foo = $cdb->get( 'somekey' );

// Writing to a CDB file
$cdb = Cdb\Writer::open( 'anotherdb.cdb' );
$cdb->set( 'somekey', $foo );
// Using the CLI
$ cdb ./myfile.cdb [get|list|match] <parameter>

Running tests

composer install --prefer-dist
composer test

History

This library was first introduced in MediaWiki 1.16 (r52203). It was split out of the MediaWiki codebase and published as an independent library during the MediaWiki 1.25 development cycle.