Line data Source code
1 : // Copyright 2019 The LevelDB-Go and Pebble 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 pebble
6 :
7 : import "github.com/cockroachdb/pebble/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 := pebble.NewCache(...)
19 : // defer c.Unref()
20 : // d, err := pebble.Open(pebble.Options{Cache: c})
21 0 : func NewCache(size int64) *cache.Cache {
22 0 : return cache.New(size)
23 0 : }
|