Tiny refactoring of page_cache::init function.

The init function only needs the 'page_cache_size' from the config, so
seems slightly nicer to pass just that.
This commit is contained in:
Heikki Linnakangas
2022-03-24 09:46:07 +02:00
parent 8437fc056e
commit c718870517
2 changed files with 4 additions and 8 deletions

View File

@@ -163,8 +163,7 @@ fn main() -> Result<()> {
// Basic initialization of things that don't change after startup
virtual_file::init(conf.max_file_descriptors);
page_cache::init(conf);
page_cache::init(conf.page_cache_size);
// Create repo and exit if init was requested
if init {

View File

@@ -53,7 +53,7 @@ use zenith_utils::{
};
use crate::layered_repository::writeback_ephemeral_file;
use crate::{config::PageServerConf, relish::RelTag};
use crate::relish::RelTag;
static PAGE_CACHE: OnceCell<PageCache> = OnceCell::new();
const TEST_PAGE_CACHE_SIZE: usize = 10;
@@ -61,11 +61,8 @@ const TEST_PAGE_CACHE_SIZE: usize = 10;
///
/// Initialize the page cache. This must be called once at page server startup.
///
pub fn init(conf: &'static PageServerConf) {
if PAGE_CACHE
.set(PageCache::new(conf.page_cache_size))
.is_err()
{
pub fn init(size: usize) {
if PAGE_CACHE.set(PageCache::new(size)).is_err() {
panic!("page cache already initialized");
}
}