Allow configuration of tidy functions. Use a closure to decide what entries

to delete. The closure takes a *bolt.Bucket and returns an integer of the
number of entries deleted.
This commit is contained in:
gmp
2018-08-09 18:21:52 -04:00
parent d6f4920507
commit 17beaca380
2 changed files with 84 additions and 20 deletions
+27
View File
@@ -0,0 +1,27 @@
package main
import (
"fmt"
"time"
"gitlab.wow.st/gmp/persist"
)
func main() {
tc := persist.TidyConfig{
Interval: 2 * time.Second,
Func:persist.ExpireAfter(-5 * time.Second),
}
persist.Init(persist.Config{Tidy: tc})
x := persistInt("x",0)
persist.Commit()
x.Set(2)
persist.Commit()
x.Set(3)
persist.Commit()
fmt.Println(x.History())
time.Sleep(time.Second * 15)
fmt.Println(x.History())
persist.Shutdown()
}