Add support for keys with ttl (#177)

* ttl support first commit

* imports fix

* put api args correction

* put options added

* upgrade method added

* upgrade log added

* v0 to v1 migration script added

* error assertion added

* temp migration dir fix

Co-authored-by: yash <yash.chandra@grabpay.com>
This commit is contained in:
Yash Suresh Chandra
2020-12-21 13:11:43 +05:30
committed by GitHub
parent f397bec88f
commit 5c6ceadac1
13 changed files with 421 additions and 61 deletions

View File

@@ -2,6 +2,7 @@ package bitcask
import (
"os"
"time"
"github.com/prologic/bitcask/internal/config"
)
@@ -26,6 +27,8 @@ const (
DefaultSync = false
// DefaultAutoRecovery is the default auto-recovery action.
CurrentDBVersion = uint32(1)
)
// Option is a function that takes a config struct and modifies it
@@ -111,5 +114,19 @@ func newDefaultConfig() *config.Config {
Sync: DefaultSync,
DirFileModeBeforeUmask: DefaultDirFileModeBeforeUmask,
FileFileModeBeforeUmask: DefaultFileFileModeBeforeUmask,
DBVersion: CurrentDBVersion,
}
}
type Feature struct {
Expiry *time.Time
}
type PutOptions func(*Feature) error
func WithExpiry(expiry time.Time) PutOptions {
return func(f *Feature) error {
f.Expiry = &expiry
return nil
}
}