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.
To use it inside your application, simply run
composer require wikimedia/cdb, or add a dependency in your
If you prefer using git, that's also an option:
git clone https://gerrit.wikimedia.org/r/p/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.
// 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:
- the interwiki cache
- the localisation cache
- Wikimedia's hetdeploy/multiversion