mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
e8a4d30139
Former-commit-id: 900e1a398fd82aa1cea4f319e89b8088dd81cf6c [formerly f172c22b12c49c0291e0d986dc4af94fcc91d192] [formerly 43c5da81442a5f0ca79a6eabb1dfdfbfb3f22680 [formerly 2694d0b183
]]
Former-commit-id: fa39d6a984adc4ca8f8c82c5df145c336885a53f [formerly 94543f8081bc18b1a39daf8500cfa7e0b1ba7393]
Former-commit-id: 809aae62e28a3f99a01854f71fcd5a85f89d2972
45 lines
1.7 KiB
Go
45 lines
1.7 KiB
Go
/*
|
|
Package bolt implements a low-level key/value store in pure Go. It supports
|
|
fully serializable transactions, ACID semantics, and lock-free MVCC with
|
|
multiple readers and a single writer. Bolt can be used for projects that
|
|
want a simple data store without the need to add large dependencies such as
|
|
Postgres or MySQL.
|
|
|
|
Bolt is a single-level, zero-copy, B+tree data store. This means that Bolt is
|
|
optimized for fast read access and does not require recovery in the event of a
|
|
system crash. Transactions which have not finished committing will simply be
|
|
rolled back in the event of a crash.
|
|
|
|
The design of Bolt is based on Howard Chu's LMDB database project.
|
|
|
|
Bolt currently works on Windows, Mac OS X, and Linux.
|
|
|
|
|
|
Basics
|
|
|
|
There are only a few types in Bolt: DB, Bucket, Tx, and Cursor. The DB is
|
|
a collection of buckets and is represented by a single file on disk. A bucket is
|
|
a collection of unique keys that are associated with values.
|
|
|
|
Transactions provide either read-only or read-write access to the database.
|
|
Read-only transactions can retrieve key/value pairs and can use Cursors to
|
|
iterate over the dataset sequentially. Read-write transactions can create and
|
|
delete buckets and can insert and remove keys. Only one read-write transaction
|
|
is allowed at a time.
|
|
|
|
|
|
Caveats
|
|
|
|
The database uses a read-only, memory-mapped data file to ensure that
|
|
applications cannot corrupt the database, however, this means that keys and
|
|
values returned from Bolt cannot be changed. Writing to a read-only byte slice
|
|
will cause Go to panic.
|
|
|
|
Keys and values retrieved from the database are only valid for the life of
|
|
the transaction. When used outside the transaction, these byte slices can
|
|
point to different data or can point to invalid memory which will cause a panic.
|
|
|
|
|
|
*/
|
|
package bolt
|