github.com/zuoyebang/bitalostable@v1.0.1-0.20240229032404-e3b99a834294/cache.go (about) 1 // Copyright 2019 The LevelDB-Go and Pebble and Bitalostored Authors. All rights reserved. Use 2 // of this source code is governed by a BSD-style license that can be found in 3 // the LICENSE file. 4 5 package bitalostable 6 7 import "github.com/zuoyebang/bitalostable/internal/cache" 8 9 // Cache exports the cache.Cache type. 10 type Cache = cache.Cache 11 12 // NewCache creates a new cache of the specified size. Memory for the cache is 13 // allocated on demand, not during initialization. The cache is created with a 14 // reference count of 1. Each DB it is associated with adds a reference, so the 15 // creator of the cache should usually release their reference after the DB is 16 // created. 17 // 18 // c := bitalostable.NewCache(...) 19 // defer c.Unref() 20 // d, err := bitalostable.Open(bitalostable.Options{Cache: c}) 21 func NewCache(size int64) *cache.Cache { 22 return cache.New(size) 23 }