2024-06-26 15:00:10 +00:00
|
|
|
import ../lib/librocksdb
|
2024-06-04 10:06:14 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
CachePtr* = ptr rocksdb_cache_t
|
|
|
|
|
|
|
|
CacheRef* = ref object
|
|
|
|
cPtr*: CachePtr
|
2024-06-28 15:57:34 +00:00
|
|
|
autoClose*: bool # if true then close will be called when it's parent is closed
|
2024-06-04 10:06:14 +00:00
|
|
|
|
2024-06-28 15:57:34 +00:00
|
|
|
proc cacheCreateLRU*(size: int, autoClose = false): CacheRef =
|
|
|
|
CacheRef(cPtr: rocksdb_cache_create_lru(size.csize_t), autoClose: autoClose)
|
2024-06-04 10:06:14 +00:00
|
|
|
|
|
|
|
proc close*(cache: CacheRef) =
|
|
|
|
if cache.cPtr != nil:
|
|
|
|
rocksdb_cache_destroy(cache.cPtr)
|
|
|
|
cache.cPtr = nil
|