Jump to content

CDB: Difference between revisions

From mediawiki.org
Content deleted Content added
Replaced content with " GAH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
m Reverted edits by 65.189.18.40 (talk) to last revision by Krinkle
Line 1: Line 1:
{{TNT|Ptag|cdb}}
'''[[w:cdb (software)|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]] ({{r|52203}}), 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 ==
GAH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
To use it inside your application, simply run <code>composer require wikimedia/cdb</code>, or add a dependency in your <code>composer.json</code>.

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

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

== Usage ==
<source lang="php">
// 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 );
</source>

For actual usage examples, you can look at the following uses within MediaWiki:
* the [[interwiki cache]]
* the [[localisation cache]]
* [[Extension:Babel]]
* [[Extension:TrustedXFF]]
* Wikimedia's [[wikitech:Heterogeneous deployment|hetdeploy/multiversion]]

==See also==
* [[Memcached]]
* [[PHP configuration]]
* http://laxstrom.name/blag/?s=cdb
* http://cr.yp.to/cdb.html

== External links ==
* [https://git.wikimedia.org/tree/?r=cdb.git Source code on git.wikimedia.org] ([https://github.com/wikimedia/cdb GitHub mirror])
* [https://packagist.org/packages/wikimedia/cdb Package on Packagist.org]
* [https://doc.wikimedia.org/cdb/master/ API Documentation]
* [[phab:tag/cdb/|Issue tracker]]

[[Category:Database]]
[[Category:PHP libraries]]

Revision as of 16:49, 12 December 2015

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

To use it inside your application, simply 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/p/cdb.git, and autoload the library however you wish to.

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

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

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

See also