leveldb/database/
cache.rs1use cruzbit_leveldb_sys::{leveldb_cache_create_lru, leveldb_cache_destroy, leveldb_cache_t};
3use libc::size_t;
4
5#[allow(missing_docs)]
6struct RawCache {
7 ptr: *mut leveldb_cache_t,
8}
9
10impl Drop for RawCache {
11 fn drop(&mut self) {
12 unsafe {
13 leveldb_cache_destroy(self.ptr);
14 }
15 }
16}
17
18pub struct Cache {
20 raw: RawCache,
21}
22
23impl Cache {
24 pub fn new(size: size_t) -> Cache {
26 let cache = unsafe { leveldb_cache_create_lru(size) };
27 Cache {
28 raw: RawCache { ptr: cache },
29 }
30 }
31
32 #[allow(missing_docs)]
33 pub fn raw_ptr(&self) -> *mut leveldb_cache_t {
34 self.raw.ptr
35 }
36}