James Kominick
James Kominick
There's no reason other than that I haven't needed it and no one's asked for it yet. We could add an option to the macro `#[cached(rwlock)]` and have it use...
Ah.. you know what... I forgot the reason a RwLock won't work is because of the signature ``` /// Attempt to retrieve a cached value fn cache_get(&mut self, k: &K)...
Since a RwLock (correctly) prevents you from mutating on reads, the only scenario where you could use a RwLock is if the backing cache is a plain HashMap with no...
Ah I see. I don’t think I’ll have time to update the macro this week, so in the meantime you could emulate what the macro would be doing (and have...
Nice. Yeah, the `already_set` bit isn't required, but it would prevent multiple concurrent calls from calling `get_new_token` when the token is missing or expired. Without it there may be multiple...
@adambezecny I'll take another look at this tonight and add a `#[once]` macro that implements the `RwLock` (only caching a single value) version we were chatting about a while ago
@adambezecny A `#[once]` macro is now available in `0.26.0` https://github.com/jaemk/cached/commit/0e36dbd894867a635c94e433604bb8333976ed24
@adambezecny `once` will always use a `RwLock`, but when `sync_writes = true` it will try to acquire the write-lock _before_ executing the function that returns the value to cache (and...
Yes, correct!
I think the difference might be because the macros expand to use `async_std`'s `async_mutex` and `async_rwlock` whereas the manual version you have is using `tokio::sync::RwLock`