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.

36 lines
700 B

  1. package meta_cache
  2. import (
  3. "os"
  4. "github.com/chrislusf/seaweedfs/weed/filer2"
  5. "github.com/chrislusf/seaweedfs/weed/filer2/leveldb"
  6. "github.com/chrislusf/seaweedfs/weed/glog"
  7. )
  8. type MetaCache struct {
  9. filer2.FilerStore
  10. }
  11. func NewMetaCache(dbFolder string) *MetaCache {
  12. return &MetaCache{
  13. FilerStore: openMetaStore(dbFolder),
  14. }
  15. }
  16. func openMetaStore(dbFolder string) filer2.FilerStore {
  17. os.RemoveAll(dbFolder)
  18. os.MkdirAll(dbFolder, 0755)
  19. store := &leveldb.LevelDBStore{}
  20. config := &cacheConfig{
  21. dir: dbFolder,
  22. }
  23. if err := store.Initialize(config, ""); err != nil {
  24. glog.Fatalf("Failed to initialize metadata cache store for %s: %+v", store.GetName(), err)
  25. }
  26. return store
  27. }