mirror of https://github.com/ledisdb/ledisdb.git
add put and delete info back
This commit is contained in:
parent
b0c808e1bd
commit
0009fe83b9
|
@ -173,31 +173,33 @@ func (i *info) dumpStore(buf *bytes.Buffer) {
|
|||
|
||||
s := i.app.ldb.StoreStat()
|
||||
|
||||
getNum := s.GetNum.Get()
|
||||
getTotalTime := s.GetTotalTime.Get()
|
||||
// getNum := s.GetNum.Get()
|
||||
// getTotalTime := s.GetTotalTime.Get()
|
||||
|
||||
gt := int64(0)
|
||||
if getNum > 0 {
|
||||
gt = getTotalTime.Nanoseconds() / (getNum * 1e3)
|
||||
}
|
||||
// gt := int64(0)
|
||||
// if getNum > 0 {
|
||||
// gt = getTotalTime.Nanoseconds() / (getNum * 1e3)
|
||||
// }
|
||||
|
||||
commitNum := s.BatchCommitNum.Get()
|
||||
commitTotalTime := s.BatchCommitTotalTime.Get()
|
||||
// commitNum := s.BatchCommitNum.Get()
|
||||
// commitTotalTime := s.BatchCommitTotalTime.Get()
|
||||
|
||||
ct := int64(0)
|
||||
if commitNum > 0 {
|
||||
ct = commitTotalTime.Nanoseconds() / (commitNum * 1e3)
|
||||
}
|
||||
// ct := int64(0)
|
||||
// if commitNum > 0 {
|
||||
// ct = commitTotalTime.Nanoseconds() / (commitNum * 1e3)
|
||||
// }
|
||||
|
||||
i.dumpPairs(buf, infoPair{"name", i.app.cfg.DBName},
|
||||
infoPair{"get", s.GetNum},
|
||||
infoPair{"get_missing", s.GetMissingNum},
|
||||
infoPair{"get_per_time", fmt.Sprintf("%0.002fms", float64(gt)/1000.0)},
|
||||
infoPair{"put", s.PutNum},
|
||||
infoPair{"delete", s.DeleteNum},
|
||||
infoPair{"get_total_time", s.GetTotalTime.Get().String()},
|
||||
infoPair{"iter", s.IterNum},
|
||||
infoPair{"iter_seek", s.IterSeekNum},
|
||||
infoPair{"iter_close", s.IterCloseNum},
|
||||
infoPair{"batch_commit", s.BatchCommitNum},
|
||||
infoPair{"batch_commit_per_time", fmt.Sprintf("%0.002fms", float64(ct)/1000.0)},
|
||||
infoPair{"batch_commit_total_time", s.BatchCommitTotalTime.Get().String()},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,19 +9,28 @@ type WriteBatch struct {
|
|||
wb driver.IWriteBatch
|
||||
st *Stat
|
||||
|
||||
putNum int64
|
||||
deleteNum int64
|
||||
db *DB
|
||||
}
|
||||
|
||||
func (wb *WriteBatch) Put(key []byte, value []byte) {
|
||||
wb.putNum++
|
||||
wb.wb.Put(key, value)
|
||||
}
|
||||
|
||||
func (wb *WriteBatch) Delete(key []byte) {
|
||||
wb.deleteNum++
|
||||
wb.wb.Delete(key)
|
||||
}
|
||||
|
||||
func (wb *WriteBatch) Commit() error {
|
||||
wb.st.BatchCommitNum.Add(1)
|
||||
wb.st.PutNum.Add(wb.putNum)
|
||||
wb.st.DeleteNum.Add(wb.deleteNum)
|
||||
wb.putNum = 0
|
||||
wb.deleteNum = 0
|
||||
|
||||
var err error
|
||||
t := time.Now()
|
||||
if wb.db == nil || !wb.db.needSyncCommit() {
|
||||
|
@ -36,5 +45,8 @@ func (wb *WriteBatch) Commit() error {
|
|||
}
|
||||
|
||||
func (wb *WriteBatch) Rollback() error {
|
||||
wb.putNum = 0
|
||||
wb.deleteNum = 0
|
||||
|
||||
return wb.wb.Rollback()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue