moka-rs / moka

A high performance concurrent caching library for Rust
Apache License 2.0
1.42k stars 62 forks source link

Should Moka work in WASM? #423

Open rogusdev opened 1 month ago

rogusdev commented 1 month ago

There is a js feature which enables uuid/js feature, to use a web safe random generator. However, it seems that Moka still uses time somewhere, because in the browser the app panics on time not implemented on this platform. I would love to be able to use Moka in a web app (rust wasm), but am not sure if this is a use case that is intended to be supported, and currently broken (or I am doing something wrong), or if this is simply not what Moka is meant for.

Thanks!

tatsuya6502 commented 1 month ago

Hi. Sorry for the confusion. Unfortunately, the js feature was half-done by #173 and I would not surprise to see it is broken. I think we should remove the feature in next release.

Currently, we have not decided whether to make Moka to support WASM platform or not. And we do not have enough resource to develop it now:

https://github.com/orgs/moka-rs/projects/1?pane=issue&itemId=49877487

Some people have asked if moka would support Wasm platform. Currently, mokas primary goal is to provide the best performance and convenient features for concurrent programing, and it conflicts with common requirements in Wasm platform.

To support Wasm, it looks like we will need to develop a complete different and very simple implementation. We will revisit this and evaluate options.

I put a list of other cache implementations (crates) in the linked issue comment above, and if you can use some of them, that would be great. But if you cannot use any of them, because e.g. missing some features you need, please let us know.

rogusdev commented 1 month ago

Thanks. I had already started using minimoka unsync so I'm good there :)

I asked this question simply because of the confusion over the feature flag not actually doing what it seemed it should.

Sounds like removing it would make sense, and thanks.

And maybe also an explicit message about wasm support somewhere!