aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md9
1 files changed, 7 insertions, 2 deletions
diff --git a/README.md b/README.md
index 8cc9f3c..18ba570 100644
--- a/README.md
+++ b/README.md
@@ -258,6 +258,10 @@ set to a key which is different than the key not existing.
Use the `Bucket.Delete()` function to delete a key from the bucket.
+Please note that values returned from `Get()` are only valid while the
+transaction is open. If you need to use a value outside of the transaction
+then you must use `copy()` to copy it to another byte slice.
+
### Iterating over keys
@@ -370,7 +374,7 @@ func (*Bucket) DeleteBucket(key []byte) error
### Database backups
-Bolt is a single file so it's easy to backup. You can use the `Tx.Copy()`
+Bolt is a single file so it's easy to backup. You can use the `Tx.WriteTo()`
function to write a consistent view of the database to a writer. If you call
this from a read-only transaction, it will perform a hot backup and not block
your other database reads and writes. It will also use `O_DIRECT` when available
@@ -385,7 +389,8 @@ func BackupHandleFunc(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", `attachment; filename="my.db"`)
w.Header().Set("Content-Length", strconv.Itoa(int(tx.Size())))
- return tx.Copy(w)
+ _, err := tx.WriteTo(w)
+ return err
})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)