peterbourgon / diskv

A disk-backed key-value store.
http://godoc.org/github.com/peterbourgon/diskv
MIT License
1.4k stars 102 forks source link

Create a new "TempDir" option for atomic write #35

Closed apelisse closed 7 years ago

apelisse commented 7 years ago

The current atomic write is somewhat broken as the temporary files are created inside the base directory, and so count as potential keys (and can conflict). Move these temporary files in the TempDir specified by the user so that they can't conflict with future keys.

Note that the TempDir must be on the same device/partition/mount or the atomic Rename will fail across partition.

Atomic write will not happen if TempDir is left empty.

apelisse commented 7 years ago

Added documentation for TempDir. PTAL