wikimedia/cdb
Constant Database (CDB) wrapper library for PHP. Provides pure-PHP fallback when dba_* functions are absent.
Maintainers
Requires
- php: >=7.4.0
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 41.0.0
- mediawiki/mediawiki-phan-config: 0.12.1
- mediawiki/minus-x: 1.1.1
- ockcyp/covers-validator: 1.6.0
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.3.2
- phpunit/phpunit: 9.5.28
Suggests
- ext-dba: PHP extension for DBA access. Would be quicker than the PHP based fallback
Provides
None
Conflicts
None
Replaces
None
GPL-2.0-or-later 3d7622f39319ea2149cac92415222d1fb39c46d0
- Tim Starling <tstarling.woop@wikimedia.org>
- Chad Horohoe <chad.woop@wikimedia.org>
- Ori Livneh <ori.woop@wikimedia.org>
- Daniel Kinzler
README
👁 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.
