1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use std::time::Duration;

/// Persy configuration structure.
///
/// Currend defaul valus;
///
/// cache_size = 32M
/// transaction_lock_timeout = 15 minutes
///
pub struct Config {
    cache_size: u64,
    transaction_lock_timeout: Duration,
}

impl Config {
    pub fn new() -> Config {
        Config {
            cache_size: 32 * 1024 * 1024,
            transaction_lock_timeout: Duration::new(15000, 0),
        }
    }

    pub fn cache_size(&self) -> u64 {
        self.cache_size
    }

    pub fn transaction_lock_timeout<'a>(&'a self) -> &'a Duration {
        &self.transaction_lock_timeout
    }

    pub fn change_cache_size(&mut self, cache_size: u64) {
        self.cache_size = cache_size;
    }

    pub fn change_transaction_lock_timeout(&mut self, transaction_lock_timeout: Duration) {
        self.transaction_lock_timeout = transaction_lock_timeout;
    }
}