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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user