actually use app.response_cache_max_bytes
This commit is contained in:
parent
5ffe2aa72a
commit
4e63e69c97
@ -669,14 +669,12 @@ impl Web3ProxyApp {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep 1GB of blocks in the cache
|
// responses can be very different in sizes, so this is a cache with a max capacity and a weigher
|
||||||
// responses can be very different in sizes, so this definitely needs a weigher
|
|
||||||
// TODO: max_capacity from config
|
|
||||||
// TODO: don't allow any response to be bigger than X% of the cache
|
// TODO: don't allow any response to be bigger than X% of the cache
|
||||||
let response_cache = Cache::builder()
|
let response_cache = Cache::builder()
|
||||||
.max_capacity(1024 * 1024 * 1024)
|
.max_capacity(top_config.app.response_cache_max_bytes)
|
||||||
.weigher(|k: &ResponseCacheKey, v| {
|
.weigher(|k: &ResponseCacheKey, v| {
|
||||||
// TODO: is this good?
|
// TODO: is this good enough?
|
||||||
if let Ok(v) = serde_json::to_string(v) {
|
if let Ok(v) = serde_json::to_string(v) {
|
||||||
let weight = k.weight() + v.len();
|
let weight = k.weight() + v.len();
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ pub struct AppConfig {
|
|||||||
|
|
||||||
/// RPC responses are cached locally
|
/// RPC responses are cached locally
|
||||||
#[serde(default = "default_response_cache_max_bytes")]
|
#[serde(default = "default_response_cache_max_bytes")]
|
||||||
pub response_cache_max_bytes: usize,
|
pub response_cache_max_bytes: u64,
|
||||||
|
|
||||||
/// the stats page url for an anonymous user.
|
/// the stats page url for an anonymous user.
|
||||||
pub redirect_public_url: Option<String>,
|
pub redirect_public_url: Option<String>,
|
||||||
@ -190,10 +190,10 @@ fn default_login_rate_limit_per_period() -> u64 {
|
|||||||
10
|
10
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_response_cache_max_bytes() -> usize {
|
fn default_response_cache_max_bytes() -> u64 {
|
||||||
// TODO: default to some percentage of the system?
|
// TODO: default to some percentage of the system?
|
||||||
// 100 megabytes
|
// 100 megabytes
|
||||||
10_usize.pow(8)
|
10u64.pow(8)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration for a backend web3 RPC server
|
/// Configuration for a backend web3 RPC server
|
||||||
|
Loading…
Reference in New Issue
Block a user