cubefs/vendor/github.com/tecbot/gorocksdb/cache.go
yuxiaobo ac75137295 build: the build script of blobstore is merged into cubefs
1. rocksdb upgrade to 6.3.6
2. optimize the build scripts
3. fix build errors
4. add env variable for blobstore unit test
5. update git ignore file to ignore build and test result
6. modify open files limit for unit test

Signed-off-by: yuxiaobo <yuxiaobo@oppo.com>
Signed-off-by: slasher <shenjie1@oppo.com>
Signed-off-by: Victor1319 <834863182@qq.com>
2023-05-23 15:24:53 +08:00

36 lines
867 B
Go

package gorocksdb
// #include "rocksdb/c.h"
import "C"
// Cache is a cache used to store data read from data in memory.
type Cache struct {
c *C.rocksdb_cache_t
}
// NewLRUCache creates a new LRU Cache object with the capacity given.
func NewLRUCache(capacity uint64) *Cache {
return NewNativeCache(C.rocksdb_cache_create_lru(C.size_t(capacity)))
}
// NewNativeCache creates a Cache object.
func NewNativeCache(c *C.rocksdb_cache_t) *Cache {
return &Cache{c}
}
// GetUsage returns the Cache memory usage.
func (c *Cache) GetUsage() uint64 {
return uint64(C.rocksdb_cache_get_usage(c.c))
}
// GetPinnedUsage returns the Cache pinned memory usage.
func (c *Cache) GetPinnedUsage() uint64 {
return uint64(C.rocksdb_cache_get_pinned_usage(c.c))
}
// Destroy deallocates the Cache object.
func (c *Cache) Destroy() {
C.rocksdb_cache_destroy(c.c)
c.c = nil
}