當前位置: 首頁>>代碼示例>>Golang>>正文


Golang config.LevelDBConfig類代碼示例

本文整理匯總了Golang中github.com/siddontang/ledisdb/config.LevelDBConfig的典型用法代碼示例。如果您正苦於以下問題:Golang LevelDBConfig類的具體用法?Golang LevelDBConfig怎麽用?Golang LevelDBConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LevelDBConfig類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: initOptions

func (db *DB) initOptions(cfg *config.LevelDBConfig) {
	opts := NewOptions()

	opts.SetCreateIfMissing(true)

	cfg.Adjust()

	db.cache = NewLRUCache(cfg.CacheSize)
	opts.SetCache(db.cache)

	//we must use bloomfilter
	db.filter = NewBloomFilter(defaultFilterBits)
	opts.SetFilterPolicy(db.filter)

	if !cfg.Compression {
		opts.SetCompression(NoCompression)
	} else {
		opts.SetCompression(SnappyCompression)
	}

	opts.SetBlockSize(cfg.BlockSize)

	opts.SetWriteBufferSize(cfg.WriteBufferSize)

	opts.SetMaxOpenFiles(cfg.MaxOpenFiles)

	db.opts = opts

	db.readOpts = NewReadOptions()
	db.writeOpts = NewWriteOptions()

	db.iteratorOpts = NewReadOptions()
	db.iteratorOpts.SetFillCache(false)
}
開發者ID:huanshi,項目名稱:ledisdb,代碼行數:34,代碼來源:db.go

示例2: initOptions

func (db *DB) initOptions(cfg *config.LevelDBConfig) {
	opts := NewOptions()
	blockOpts := NewBlockBasedTableOptions()

	opts.SetCreateIfMissing(true)

	cfg.Adjust()

	db.env = NewDefaultEnv()
	db.env.SetBackgroundThreads(runtime.NumCPU() * 2)
	db.env.SetHighPriorityBackgroundThreads(1)
	opts.SetEnv(db.env)

	db.cache = NewLRUCache(cfg.CacheSize)
	blockOpts.SetCache(db.cache)

	//we must use bloomfilter
	db.filter = NewBloomFilter(defaultFilterBits)
	blockOpts.SetFilterPolicy(db.filter)

	if !cfg.Compression {
		opts.SetCompression(NoCompression)
	} else {
		opts.SetCompression(SnappyCompression)
	}

	blockOpts.SetBlockSize(cfg.BlockSize)

	opts.SetWriteBufferSize(cfg.WriteBufferSize)

	opts.SetMaxOpenFiles(cfg.MaxOpenFiles)

	opts.SetMaxBackgroundCompactions(runtime.NumCPU()*2 - 1)
	opts.SetMaxBackgroundFlushes(1)

	opts.SetLevel0SlowdownWritesTrigger(16)
	opts.SetLevel0StopWritesTrigger(64)
	opts.SetTargetFileSizeBase(32 * 1024 * 1024)

	opts.SetBlockBasedTableFactory(blockOpts)

	db.opts = opts
	db.blockOpts = blockOpts

	db.readOpts = NewReadOptions()
	db.writeOpts = NewWriteOptions()

	db.iteratorOpts = NewReadOptions()
	db.iteratorOpts.SetFillCache(false)
}
開發者ID:Abioy,項目名稱:ledisdb,代碼行數:50,代碼來源:db.go

示例3: newOptions

func newOptions(cfg *config.LevelDBConfig) *opt.Options {
	opts := &opt.Options{}
	opts.ErrorIfMissing = false

	cfg.Adjust()

	opts.BlockCache = cache.NewLRUCache(cfg.CacheSize)

	//we must use bloomfilter
	opts.Filter = filter.NewBloomFilter(defaultFilterBits)

	if !cfg.Compression {
		opts.Compression = opt.NoCompression
	} else {
		opts.Compression = opt.SnappyCompression
	}

	opts.BlockSize = cfg.BlockSize
	opts.WriteBuffer = cfg.WriteBufferSize

	return opts
}
開發者ID:huanshi,項目名稱:ledisdb,代碼行數:22,代碼來源:db.go


注:本文中的github.com/siddontang/ledisdb/config.LevelDBConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。