Browse Source

optionally open the leveldb in readonly mode

pull/5719/head
chrislu 6 months ago
parent
commit
cb67137a03
  1. 2
      weed/filer/leveldb2/leveldb2_store.go
  2. 3
      weed/filer/leveldb3/leveldb3_store.go

2
weed/filer/leveldb2/leveldb2_store.go

@ -27,6 +27,7 @@ func init() {
type LevelDB2Store struct {
dbs []*leveldb.DB
dbCount int
ReadOnly bool
}
func (store *LevelDB2Store) GetName() string {
@ -49,6 +50,7 @@ func (store *LevelDB2Store) initialize(dir string, dbCount int) (err error) {
BlockCacheCapacity: 32 * 1024 * 1024, // default value is 8MiB
WriteBuffer: 16 * 1024 * 1024, // default value is 4MiB
Filter: filter.NewBloomFilter(8), // false positive rate 0.02
ReadOnly: store.ReadOnly,
}
for d := 0; d < dbCount; d++ {

3
weed/filer/leveldb3/leveldb3_store.go

@ -34,6 +34,7 @@ type LevelDB3Store struct {
dir string
dbs map[string]*leveldb.DB
dbsLock sync.RWMutex
ReadOnly bool
}
func (store *LevelDB3Store) GetName() string {
@ -69,12 +70,14 @@ func (store *LevelDB3Store) loadDB(name string) (*leveldb.DB, error) {
BlockCacheCapacity: 32 * 1024 * 1024, // default value is 8MiB
WriteBuffer: 16 * 1024 * 1024, // default value is 4MiB
Filter: bloom,
ReadOnly: store.ReadOnly,
}
if name != DEFAULT {
opts = &opt.Options{
BlockCacheCapacity: 16 * 1024 * 1024, // default value is 8MiB
WriteBuffer: 8 * 1024 * 1024, // default value is 4MiB
Filter: bloom,
ReadOnly: store.ReadOnly,
}
}

Loading…
Cancel
Save