diff --git a/config/config.go b/config/config.go index f11c335..e75bca4 100644 --- a/config/config.go +++ b/config/config.go @@ -113,7 +113,7 @@ type Config struct { ConnReadBufferSize int `toml:"conn_read_buffer_size"` ConnWriteBufferSize int `toml:"conn_write_buffer_size"` - ConnKeepaliveInterval int `toml:"conn_keepavlie_interval"` + ConnKeepaliveInterval int `toml:"conn_keepalive_interval"` TTLCheckInterval int `toml:"ttl_check_interval"` } diff --git a/config/config.toml b/config/config.toml index 6b6722b..f75c784 100644 --- a/config/config.toml +++ b/config/config.toml @@ -50,7 +50,7 @@ conn_write_buffer_size = 10240 # if connection receives no data after n seconds, it may be dead, close # 0 to disable and not check -conn_keepavlie_interval = 0 +conn_keepalive_interval = 0 # checking TTL (time to live) data every n seconds # if you set big, the expired data may not be deleted immediately diff --git a/etc/ledis.conf b/etc/ledis.conf index 6b6722b..f75c784 100644 --- a/etc/ledis.conf +++ b/etc/ledis.conf @@ -50,7 +50,7 @@ conn_write_buffer_size = 10240 # if connection receives no data after n seconds, it may be dead, close # 0 to disable and not check -conn_keepavlie_interval = 0 +conn_keepalive_interval = 0 # checking TTL (time to live) data every n seconds # if you set big, the expired data may not be deleted immediately diff --git a/server/info.go b/server/info.go index 1b7d27d..0e807c1 100644 --- a/server/info.go +++ b/server/info.go @@ -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()}, ) } diff --git a/store/writebatch.go b/store/writebatch.go index 773eeaf..a7fd84a 100644 --- a/store/writebatch.go +++ b/store/writebatch.go @@ -9,19 +9,28 @@ type WriteBatch struct { wb driver.IWriteBatch st *Stat - db *DB + 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() }