U:RDoc::NormalClass[iI"DBM:ET@I" Object;To:RDoc::Markup::Document: @parts[o;;[S:RDoc::Markup::Heading: leveli: textI"Introduction;To:RDoc::Markup::BlankLineo:RDoc::Markup::Paragraph;[I"6The DBM class provides a wrapper to a Unix-style ;TI"I{dbm}[http://en.wikipedia.org/wiki/Dbm] or Database Manager library.;T@o; ;[I"LDbm databases do not have tables or columns; they are simple key-value ;TI"Odata stores, like a Ruby Hash except not resident in RAM. Keys and values ;TI"must be strings.;T@o; ;[I"NThe exact library used depends on how Ruby was compiled. It could be any ;TI"of the following:;T@o:RDoc::Markup::List: @type: BULLET: @items[ o:RDoc::Markup::ListItem: @label0;[o; ;[I"6The original ndbm library is released in 4.3BSD. ;TI"KIt is based on dbm library in Unix Version 7 but has different API to ;TI"-support multiple databases in a process.;To;;0;[o; ;[I"F{Berkeley DB}[http://en.wikipedia.org/wiki/Berkeley_DB] versions ;TI"G1 thru 5, also known as BDB and Sleepycat DB, now owned by Oracle ;TI"Corporation.;To;;0;[o; ;[I"PBerkeley DB 1.x, still found in 4.4BSD derivatives (FreeBSD, OpenBSD, etc).;To;;0;[o; ;[I"N{gdbm}[http://www.gnu.org/software/gdbm/], the GNU implementation of dbm.;To;;0;[o; ;[I"E{qdbm}[http://fallabs.com/qdbm/index.html], another open source ;TI"reimplementation of dbm.;T@o; ;[I"EAll of these dbm implementations have their own Ruby interfaces ;TI"8available, which provide richer (but varying) APIs.;T@S; ; i; I" Cautions;T@o; ;[I"MBefore you decide to use DBM, there are some issues you should consider:;T@o;;;;[ o;;0;[o; ;[I"HEach implementation of dbm has its own file format. Generally, dbm ;TI"Flibraries will not read each other's files. This makes dbm files ;TI"$a bad choice for data exchange.;T@o;;0;[o; ;[I"LEven running the same OS and the same dbm implementation, the database ;TI"Lfile format may depend on the CPU architecture. For example, files may ;TI"Mnot be portable between PowerPC and 386, or between 32 and 64 bit Linux.;T@o;;0;[o; ;[I"ODifferent versions of Berkeley DB use different file formats. A change to ;TI"=the OS may therefore break DBM access to existing files.;T@o;;0;[o; ;[ I"MData size limits vary between implementations. Original Berkeley DB was ;TI"Jlimited to 2GB of data. Dbm libraries also sometimes limit the total ;TI"Lsize of a key/value pair, and the total size of all the keys that hash ;TI"Oto the same value. These limits can be as little as 512 bytes. That said, ;TI"Ggdbm and recent versions of Berkeley DB do away with these limits.;T@o; ;[I"QGiven the above cautions, DBM is not a good choice for long term storage of ;TI"Mimportant data. It is probably best used as a fast and easy alternative ;TI"4to a Hash for processing large amounts of data.;T@S; ; i; I" Example;T@o:RDoc::Markup::Verbatim;[ I"require 'dbm' ;TI"/db = DBM.open('rfcs', 0666, DBM::WRCREAT) ;TI"Jdb['822'] = 'Standard for the Format of ARPA Internet Text Messages' ;TI"Ndb['1123'] = 'Requirements for Internet Hosts - Application and Support' ;TI"=db['3068'] = 'An Anycast Prefix for 6to4 Relay Routers' ;TI"puts db['822'];T: @format0: @fileI"ext/dbm/dbm.c;T:0@omit_headings_from_table_of_contents_below0;0;0[[ U:RDoc::Constant[iI" READER;TI"DBM::READER;T00o;;[o; ;[I"IIndicates that dbm_open() should open the database in read-only mode;T@;@t;0@t@cRDoc::NormalClass0U;[iI" WRITER;TI"DBM::WRITER;T00o;;[o; ;[I"JIndicates that dbm_open() should open the database in read/write mode;T@;@t;0@t@@{0U;[iI" WRCREAT;TI"DBM::WRCREAT;T00o;;[o; ;[I"LIndicates that dbm_open() should open the database in read/write mode, ;TI"/and create it if it does not already exist;T;@t;0@t@@{0U;[iI" NEWDB;TI"DBM::NEWDB;T00o;;[o; ;[I"LIndicates that dbm_open() should open the database in read/write mode, ;TI"Kcreate it if it does not already exist, and delete all contents if it ;TI"does already exist.;T;@t;0@t@@{0U;[iI" VERSION;TI"DBM::VERSION;T00o;;[ o; ;[I"%Identifies ndbm library version.;T@o; ;[I"Examples:;T@o;;;;[ o;;0;[o; ;[I""ndbm (4.3BSD)";To;;0;[o; ;[I"+"Berkeley DB 4.8.30: (April 9, 2010)";To;;0;[o; ;[I","Berkeley DB (unknown)" (4.4BSD, maybe);To;;0;[o; ;[I"B"GDBM version 1.8.3. 10/15/2002 (built Jul 1 2011 12:32:45)";To;;0;[o; ;[I""QDBM 1.8.78";T;@t;0@t@@{0[[I"Enumerable;To;;[;@t;0I"ext/dbm/dbm.c;T[[I" class;T[[: public[[I"new;T@Æ[I" open;T@Æ[:protected[[: private[[I" instance;T[[;[([I"[];T@Æ[I"[]=;T@Æ[I" clear;T@Æ[I" close;T@Æ[I" closed?;T@Æ[I" delete;T@Æ[I"delete_if;T@Æ[I" each;T@Æ[I" each_key;T@Æ[I"each_pair;T@Æ[I"each_value;T@Æ[I" empty?;T@Æ[I" fetch;T@Æ[I" has_key?;T@Æ[I"has_value?;T@Æ[I" include?;T@Æ[I" invert;T@Æ[I"key;T@Æ[I" key?;T@Æ[I" keys;T@Æ[I" length;T@Æ[I" member?;T@Æ[I" reject;T@Æ[I" reject!;T@Æ[I" replace;T@Æ[I" select;T@Æ[I" shift;T@Æ[I" size;T@Æ[I" store;T@Æ[I" to_a;T@Æ[I" to_hash;T@Æ[I" update;T@Æ[I" value?;T@Æ[I" values;T@Æ[I"values_at;T@Æ[;[[;[[[U:RDoc::Context::Section[i0o;;[;0;0[@t@tcRDoc::TopLevel