seaweedfs/weed/filesys/meta_cache/meta_cache.go
Chris Lu 4f02f7121d read from meta cache
meta cache is not initialized
2020-04-21 18:50:30 -07:00

35 lines
658 B
Go

package meta_cache
import (
"os"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/filer2/leveldb"
"github.com/chrislusf/seaweedfs/weed/glog"
)
type MetaCache struct {
filer2.FilerStore
}
func NewMetaCache(dbFolder string) *MetaCache {
return &MetaCache{
FilerStore: OpenMetaStore(dbFolder),
}
}
func OpenMetaStore(dbFolder string) filer2.FilerStore {
os.MkdirAll(dbFolder, 0755)
store := &leveldb.LevelDBStore{}
config := &cacheConfig{}
if err := store.Initialize(config, ""); err != nil {
glog.Fatalf("Failed to initialize metadata cache store for %s: %+v", store.GetName(), err)
}
return store
}