增加网站每日独立IP统计
This commit is contained in:
@@ -4,6 +4,7 @@ package kvstore
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/cockroachdb/pebble"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -52,6 +53,29 @@ func (this *DB) Store() *Store {
|
||||
return this.store
|
||||
}
|
||||
|
||||
func (this *DB) Inspect(fn func(key []byte, value []byte)) error {
|
||||
it, err := this.store.rawDB.NewIter(&pebble.IterOptions{
|
||||
LowerBound: []byte(this.namespace),
|
||||
UpperBound: append([]byte(this.namespace), 0xFF, 0xFF),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = it.Close()
|
||||
}()
|
||||
|
||||
for it.First(); it.Valid(); it.Next() {
|
||||
value, valueErr := it.ValueAndErr()
|
||||
if valueErr != nil {
|
||||
return valueErr
|
||||
}
|
||||
fn(it.Key(), value)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Truncate the database
|
||||
func (this *DB) Truncate() error {
|
||||
this.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user