persist/test/tidy/main.go
Greg 17beaca380 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.
2018-08-09 18:21:52 -04:00

28 lines
433 B
Go

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()
}