Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-ds-badger
Commits
537179a3
Unverified
Commit
537179a3
authored
Oct 23, 2019
by
Steven Allen
Committed by
GitHub
Oct 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74 from ipfs/feat/disable-gc
feat(gc): make it possible to disable GC
parents
7d3125da
fe6e0b52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
datastore.go
datastore.go
+15
-2
No files found.
datastore.go
View file @
537179a3
...
@@ -48,9 +48,14 @@ type Options struct {
...
@@ -48,9 +48,14 @@ type Options struct {
GcDiscardRatio
float64
GcDiscardRatio
float64
// Interval between GC cycles
// Interval between GC cycles
//
// If zero, the datastore will perform no automatic garbage collection.
GcInterval
time
.
Duration
GcInterval
time
.
Duration
// Sleep time between rounds of a single GC cycle.
// Sleep time between rounds of a single GC cycle.
//
// If zero, the datastore will only perform one round of GC per
// GcInterval.
GcSleep
time
.
Duration
GcSleep
time
.
Duration
badger
.
Options
badger
.
Options
...
@@ -96,6 +101,12 @@ func NewDatastore(path string, options *Options) (*Datastore, error) {
...
@@ -96,6 +101,12 @@ func NewDatastore(path string, options *Options) (*Datastore, error) {
gcInterval
=
options
.
GcInterval
gcInterval
=
options
.
GcInterval
}
}
if
gcSleep
<=
0
{
// If gcSleep is 0, we don't perform multiple rounds of GC per
// cycle.
gcSleep
=
gcInterval
}
opt
.
Dir
=
path
opt
.
Dir
=
path
opt
.
ValueDir
=
path
opt
.
ValueDir
=
path
opt
.
Logger
=
log
opt
.
Logger
=
log
...
@@ -116,8 +127,10 @@ func NewDatastore(path string, options *Options) (*Datastore, error) {
...
@@ -116,8 +127,10 @@ func NewDatastore(path string, options *Options) (*Datastore, error) {
gcInterval
:
gcInterval
,
gcInterval
:
gcInterval
,
}
}
// schedule periodic GC till db is closed
// Start the GC process if requested.
go
ds
.
periodicGC
()
if
ds
.
gcInterval
>
0
{
go
ds
.
periodicGC
()
}
return
ds
,
nil
return
ds
,
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment