a simple url shortening service, in the same vein as bit.ly and tinyurl.com, written in Go and using BoltDB as a backend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines

  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. Bolt is a single-level, zero-copy, B+tree data store. This means that Bolt is
  8. optimized for fast read access and does not require recovery in the event of a
  9. system crash. Transactions which have not finished committing will simply be
  10. rolled back in the event of a crash.
  11. The design of Bolt is based on Howard Chu's LMDB database project.
  12. Bolt currently works on Windows, Mac OS X, and Linux.
  13. Basics
  14. There are only a few types in Bolt: DB, Bucket, Tx, and Cursor. The DB is
  15. a collection of buckets and is represented by a single file on disk. A bucket is
  16. a collection of unique keys that are associated with values.
  17. Transactions provide either read-only or read-write access to the database.
  18. Read-only transactions can retrieve key/value pairs and can use Cursors to
  19. iterate over the dataset sequentially. Read-write transactions can create and
  20. delete buckets and can insert and remove keys. Only one read-write transaction
  21. is allowed at a time.
  22. Caveats
  23. The database uses a read-only, memory-mapped data file to ensure that
  24. applications cannot corrupt the database, however, this means that keys and
  25. values returned from Bolt cannot be changed. Writing to a read-only byte slice
  26. will cause Go to panic.
  27. Keys and values retrieved from the database are only valid for the life of
  28. the transaction. When used outside the transaction, these byte slices can
  29. point to different data or can point to invalid memory which will cause a panic.
  30. */
  31. package bbolt