use cache builder for row and table cache options

add cache check using multi-get path

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-01-18 01:34:14 +00:00
commit 96e85adc32
5 changed files with 90 additions and 34 deletions

View file

@ -4,7 +4,7 @@ use std::{
};
use conduwuit::{debug, utils::math::usize_from_f64, Result, Server};
use rocksdb::{Cache, Env};
use rocksdb::{Cache, Env, LruCacheOptions};
use crate::{or_else, pool::Pool};
@ -25,12 +25,21 @@ impl Context {
let config = &server.config;
let cache_capacity_bytes = config.db_cache_capacity_mb * 1024.0 * 1024.0;
let row_cache_capacity_bytes = usize_from_f64(cache_capacity_bytes * 0.50)?;
let row_cache = Cache::new_lru_cache(row_cache_capacity_bytes);
let col_shard_bits = 7;
let col_cache_capacity_bytes = usize_from_f64(cache_capacity_bytes * 0.50)?;
let col_cache = Cache::new_lru_cache(col_cache_capacity_bytes);
let row_shard_bits = 7;
let row_cache_capacity_bytes = usize_from_f64(cache_capacity_bytes * 0.50)?;
let mut row_cache_opts = LruCacheOptions::default();
row_cache_opts.set_num_shard_bits(row_shard_bits);
row_cache_opts.set_capacity(row_cache_capacity_bytes);
let row_cache = Cache::new_lru_cache_opts(&row_cache_opts);
let mut col_cache_opts = LruCacheOptions::default();
col_cache_opts.set_num_shard_bits(col_shard_bits);
col_cache_opts.set_capacity(col_cache_capacity_bytes);
let col_cache = Cache::new_lru_cache_opts(&col_cache_opts);
let col_cache: BTreeMap<_, _> = [("Shared".to_owned(), col_cache)].into();
let mut env = Env::new().or_else(or_else)?;