You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
872 B

  1. package leveldb
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/seaweedfs/weed/filer2"
  5. "github.com/chrislusf/seaweedfs/weed/util"
  6. )
  7. var (
  8. _ = filer2.FilerLocalStore(&LevelDB2Store{})
  9. )
  10. func (store *LevelDB2Store) UpdateOffset(filer string, lastTsNs int64) error {
  11. value := make([]byte, 8)
  12. util.Uint64toBytes(value, uint64(lastTsNs))
  13. err := store.dbs[0].Put([]byte("meta"+filer), value, nil)
  14. if err != nil {
  15. return fmt.Errorf("UpdateOffset %s : %v", filer, err)
  16. }
  17. println("UpdateOffset", filer, "lastTsNs", lastTsNs)
  18. return nil
  19. }
  20. func (store *LevelDB2Store) ReadOffset(filer string) (lastTsNs int64, err error) {
  21. value, err := store.dbs[0].Get([]byte("meta"+filer), nil)
  22. if err != nil {
  23. return 0, fmt.Errorf("ReadOffset %s : %v", filer, err)
  24. }
  25. lastTsNs = int64(util.BytesToUint64(value))
  26. println("ReadOffset", filer, "lastTsNs", lastTsNs)
  27. return
  28. }