You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the discussion in #20, it looks like the expected behaviour of io_cached with disk=true is that the cache should persist between runs. I'm not sure if persistence functionality has been implemented yet, but is just bugged, or if it just hasn't been implemented yet, but I don't see persistence behaviour.
Info:
Version 0.49.2 (latest)
Also tested with current main
To reproduce
With the example code, run cargo run more than once.
(additionaly adding a time argument to the io_cached macro gives the same behaviour)
Expected:
$: cargo run
Calculating...
4
4
$: cargo run
4
4
Actual:
$: cargo run
Calculating...
4
4
$: cargo run
Calculating...
4
4
Example code
use cached::proc_macro::io_cached;#[derive(Debug, thiserror::Error)]pubenumExampleError{#[error("Disk error: {0}")]DiskError(String),}#[io_cached( map_error = r##"|e| ExampleError::DiskError(format!("{:?}", e))"##, disk = true)]fntimes_2(input:i32) -> Result<i32,ExampleError>{println!("Calculating...");// show we're not hitting the cacheOk(input *2)}fnmain(){println!("{}", times_2(2).unwrap());// this could initialize the cache if it's not alreadyprintln!("{}", times_2(2).unwrap());// get immediate result from cache}
Suggestions:
Document the lack of persistence.
Implement persistence.
Add tests for persistence (this would be slightly more involved than a usual lib test as would require spawning separate sub-processes)
The text was updated successfully, but these errors were encountered:
Ok, I've had a dig, and we're using sled. sled has it's own rules about when it synchronises to disk I think, I don't know if it does it automatically on some timescale, but sled's Db::flush() synchronises to disk.
One solution then would be to call connection.flush() after setting a cache value.
From the discussion in #20, it looks like the expected behaviour of
io_cached
withdisk=true
is that the cache should persist between runs. I'm not sure if persistence functionality has been implemented yet, but is just bugged, or if it just hasn't been implemented yet, but I don't see persistence behaviour.Info:
Version 0.49.2 (latest)
Also tested with current main
To reproduce
With the example code, run cargo run more than once.
(additionaly adding a time argument to the io_cached macro gives the same behaviour)
Expected:
Actual:
Example code
Suggestions:
The text was updated successfully, but these errors were encountered: