CubDB.compact
You're seeing just the function
compact
, go back to CubDB module for more information.
Specs
compact(GenServer.server()) :: :ok | {:error, String.t()}
Runs a database compaction.
As write operations are performed on a database, its file grows. Occasionally, a compaction operation can be run to shrink the file to its optimal size. Compaction runs in the background and does not block operations.
Only one compaction operation can run at any time, therefore if this function
is called when a compaction is already running, it returns {:error, :pending_compaction}
.
When compacting, CubDB
will create a new data file, and eventually switch to
it and remove the old one as the compaction succeeds. For this reason, during
a compaction, there should be enough disk space for a second copy of the
database file.
Compaction can create disk contention, so it should not be performed unnecessarily often.