...

Source file src/go.etcd.io/bbolt/doc.go

Documentation: go.etcd.io/bbolt

     1  /*
     2  package bbolt implements a low-level key/value store in pure Go. It supports
     3  fully serializable transactions, ACID semantics, and lock-free MVCC with
     4  multiple readers and a single writer. Bolt can be used for projects that
     5  want a simple data store without the need to add large dependencies such as
     6  Postgres or MySQL.
     7  
     8  Bolt is a single-level, zero-copy, B+tree data store. This means that Bolt is
     9  optimized for fast read access and does not require recovery in the event of a
    10  system crash. Transactions which have not finished committing will simply be
    11  rolled back in the event of a crash.
    12  
    13  The design of Bolt is based on Howard Chu's LMDB database project.
    14  
    15  Bolt currently works on Windows, Mac OS X, and Linux.
    16  
    17  # Basics
    18  
    19  There are only a few types in Bolt: DB, Bucket, Tx, and Cursor. The DB is
    20  a collection of buckets and is represented by a single file on disk. A bucket is
    21  a collection of unique keys that are associated with values.
    22  
    23  Transactions provide either read-only or read-write access to the database.
    24  Read-only transactions can retrieve key/value pairs and can use Cursors to
    25  iterate over the dataset sequentially. Read-write transactions can create and
    26  delete buckets and can insert and remove keys. Only one read-write transaction
    27  is allowed at a time.
    28  
    29  # Caveats
    30  
    31  The database uses a read-only, memory-mapped data file to ensure that
    32  applications cannot corrupt the database, however, this means that keys and
    33  values returned from Bolt cannot be changed. Writing to a read-only byte slice
    34  will cause Go to panic.
    35  
    36  Keys and values retrieved from the database are only valid for the life of
    37  the transaction. When used outside the transaction, these byte slices can
    38  point to different data or can point to invalid memory which will cause a panic.
    39  */
    40  package bbolt
    41  

View as plain text