Builds a [`Cache`] from the configuration and spawns the cache worker. If you want to load the cache configuration from a file, use [`CacheConfig::from_file`]. You can call [`CacheConfig::new`] for the default configuration. # Errors Returns an error if the configuration is invalid.
(mut config: CacheConfig)
| 52 | /// # Errors |
| 53 | /// Returns an error if the configuration is invalid. |
| 54 | pub fn new(mut config: CacheConfig) -> Result<Self> { |
| 55 | config.validate()?; |
| 56 | Ok(Self { |
| 57 | worker: Worker::start_new(&config), |
| 58 | config, |
| 59 | state: Default::default(), |
| 60 | }) |
| 61 | } |
| 62 | |
| 63 | /// Loads cache configuration specified at `path`. |
| 64 | /// |