zhangzengfei
2021-11-12 33cc2473a3d6ca941717c557f8e72b9904fbdc4f
api.go
@@ -1,5 +1,7 @@
package boltcache
import "strconv"
//添加一条日志
func (ls *LogStore) ApplyLog(logData []byte) {
   lastLogIndex := ls.getLastLog()
@@ -49,6 +51,28 @@
   return nil
}
// 遍历数据, 输出原始数据
func (ls *LogStore) ForEach(f func(v []byte) error) {
   ls.store.ForEach(f)
}
func (ls *LogStore) Size() int {
   start, _ := ls.store.FirstIndex(confBucket)
   end, _ := ls.store.LastIndex(confBucket)
   totalSize := 0
   for ; start <= end; start++ {
      bucketName := bucketPre + strconv.Itoa(int(start))
      bucketSize, err := ls.store.Size(bucketName)
      if err == nil {
         totalSize = totalSize + bucketSize
      }
   }
   return totalSize
}
//提供给外层使用,删除日志
func (ls *LogStore) Delete(lc *LogCon) error {
   return ls.store.Delete(lc)