add cache functions

master
Tyler Neely 10 years ago
parent 7369664261
commit 0db7837dd1
  1. 6
      README.md
  2. 6
      src/ffi.rs
  3. 1
      src/lib.rs
  4. 20
      src/rocksdb.rs

@ -109,14 +109,14 @@ fn tuned_for_somebody_elses_disk() -> RocksDB {
- [x] rocksdb compiled via cargo
- [x] OSX support
- [x] rustic merge operator
- [x] compaction filter, style
- [x] LRU cache
- [x] destroy/repair
- [ ] batch
- [ ] iterator
- [ ] range
- [ ] create/release snapshot
- [ ] column family operations
- [ ] compaction filter, style
- [ ] LRU cache
- [ ] destroy/repair
- [ ] comparator
- [ ] slicetransform
- [ ] windows support

@ -24,6 +24,12 @@ pub fn new_bloom_filter(bits: c_int) -> RocksDBFilterPolicy {
}
}
pub fn new_cache(capacity: size_t) -> RocksDBCache {
unsafe {
rocksdb_cache_create_lru(capacity)
}
}
#[repr(C)]
pub enum RocksDBCompressionType {
RocksDBNoCompression = 0,

@ -5,6 +5,7 @@
pub use ffi as rocksdb_ffi;
pub use ffi::{
new_bloom_filter,
new_cache,
RocksDBUniversalCompactionStyle,
RocksDBCompactionStyle,
RocksDBCompressionType,

@ -101,6 +101,26 @@ impl RocksDBOptions {
}
}
pub fn set_cache(&self, cache: rocksdb_ffi::RocksDBCache) {
unsafe {
rocksdb_ffi::rocksdb_block_based_options_set_block_cache(
self.block_options, cache);
rocksdb_ffi::rocksdb_options_set_block_based_table_factory(
self.inner,
self.block_options);
}
}
pub fn set_cache_compressed(&self, cache: rocksdb_ffi::RocksDBCache) {
unsafe {
rocksdb_ffi::rocksdb_block_based_options_set_block_cache_compressed(
self.block_options, cache);
rocksdb_ffi::rocksdb_options_set_block_based_table_factory(
self.inner,
self.block_options);
}
}
pub fn set_max_open_files(&self, nfiles: c_int) {
unsafe {
rocksdb_ffi::rocksdb_options_set_max_open_files(self.inner, nfiles);

Loading…
Cancel
Save