2014-05-22 16:02:22 +04:00
|
|
|
package ledis
|
|
|
|
|
2014-06-03 11:40:10 +04:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (db *DB) FlushAll() (drop int64, err error) {
|
2014-05-22 16:02:22 +04:00
|
|
|
all := [...](func() (int64, error)){
|
2014-06-03 11:40:10 +04:00
|
|
|
db.Flush,
|
2014-05-22 16:02:22 +04:00
|
|
|
db.LFlush,
|
|
|
|
db.HFlush,
|
|
|
|
db.ZFlush}
|
|
|
|
|
|
|
|
for _, flush := range all {
|
|
|
|
if n, e := flush(); e != nil {
|
|
|
|
err = e
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
drop += n
|
|
|
|
}
|
|
|
|
}
|
2014-06-03 11:40:10 +04:00
|
|
|
|
2014-05-22 16:02:22 +04:00
|
|
|
return
|
|
|
|
}
|
2014-06-03 11:40:10 +04:00
|
|
|
|
|
|
|
func (db *DB) activeExpireCycle() {
|
|
|
|
eliminator := newEliminator(db)
|
|
|
|
eliminator.regRetireContext(kvExpType, db.kvTx, db.delete)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
for {
|
|
|
|
eliminator.active()
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|