CDB, short for "constant database", refers to a very fast and highly reliable database system which uses a simple file with key value pairs. In MediaWiki 1.16 (r52203), a PHP port of CDB was added. Starting with MediaWiki 1.25, it was split out into a separate library which can be used independently of MediaWiki.

Installing edit

To use it inside your application, run composer require wikimedia/cdb, or add a dependency in your composer.json.

If you prefer using git, that's also an option: git clone https://gerrit.wikimedia.org/r/cdb.git, and autoload the library however you wish to.

If you wish to develop and contribute on the library, see developer account for gaining access to our code review system.

Usage edit

// 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 );

For actual usage examples, you can look at the following uses within MediaWiki:

Code stewardship edit

See also edit

External links edit