func NewWithConfig(cfg Config) *MemDB { m := &MemDB{ snapshots: skiplist.New(), gcsnapshots: skiplist.New(), currSn: 1, Config: cfg, gcchan: make(chan *skiplist.Node, gcchanBufSize), id: int(atomic.AddInt64(&dbInstancesCount, 1)), } m.freechan = make(chan *skiplist.Node, gcchanBufSize) m.store = skiplist.NewWithConfig(m.newStoreConfig()) m.initSizeFuns() buf := dbInstances.MakeBuf() defer dbInstances.FreeBuf(buf) dbInstances.Insert(unsafe.Pointer(m), CompareMemDB, buf, &dbInstances.Stats) return m }
func init() { dbInstances = skiplist.New() }