-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm compatibility - change Expiry to avoid needing std::time::Instant::now() #321
Comments
Hi. Thank you for the idea! Unfortunately, there is another feature request to expose the metadata of cached entries; many of the values in the metadata are I am not sure what to do (yet), but maybe we will add a crate feature, and when it is enabled, use |
By the way, if you do not need A while ago, I was able to build and run very basic stuff for |
I do not have enough knowledge and experience in wasm to make a good decision on this, but I think moka would not be a good choice for a product that runs on moka has the following downsides when used in a wasm target:
Have you checked other crates that provide smaller feature sets? You may want to check the following crates:
and maybe you want to tell us what features are missing from mini-moka for your project. |
Closing as there are no activities. Feel free to reopen if needed. |
When creating a new moka::sync::Cache on wasm32-unknown-unknown, a panic results:
time is not implemented on this platform
. This is becausestd::time::Instant::now()
is being called.moka already has a
quanta
feature which uses its version ofInstant
that supports wasm32-unknown-unknown. But despite that feature being enabled,std::time::Instant
is also used.It appears necessary because of the
pub trait Expiry
which provides configurable behavior based onstd::time::Instant
:current_time
andlast_modified_at
. That means resolving this issue — enabling moka::sync::Cache on wasm — requires a breaking change to the API.The Expiry trait could be changed as follows:
current_time
is generally unnecessary as the implementation can do it if desired, andlast_modified_at
may instead be something likeduration_since_modified
. E.g.:The text was updated successfully, but these errors were encountered: