Comments (3)
The reason:
the worker threads will create a new state for each thread. So it must be done by ways like .clone()
from moka.
To be more specific:
I'm using it with actix-web
.
At the beginning, it works fine:
let c = Cache::builder()
.time_to_live(Duration::from_secs(60 * 60 * 24)) // live, 24h
.build(),
let app = MyStruct{c};
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(app.clone()))
//....
}).bind(("0.0.0.0", 8888))?
.run()
.await;
But after I changed to:
let c = Cache::builder()
.time_to_live(Duration::from_secs(60 * 60 * 24)) // live, 24h
.build(),
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(MyStruct{c})) // Now inside
//....
}).bind(("0.0.0.0", 8888))?
.run()
.await;
And the problem occurs.
from moka.
Is this a problem with the smart pointers, and maybe the underlying issue is something inside the unsafe impl Send/Sync
?
from moka.
Related Issues (20)
- Refactoring: Cache policy implementations HOT 2
- Do not swallow the panic when the eviction listener is panicked
- Crash in iOS HOT 3
- Unable to use moka when miri testing HOT 3
- Inefficient size aware eviction when inserting new entries with larger size HOT 3
- Consider switching to TinyUFO HOT 2
- Pending `run_pending_tasks` may cause busy loop in `schedule_write_op` HOT 14
- Miri errors on the `timer_wheel` module. (Miri v0.1.0 8b2459c1 2024-04-09) HOT 1
- CI: Kani verifier v0.49.0 uses Rust `nightly-2024-03-29`, which cannot compile `[email protected]` HOT 2
- Should Moka work in WASM? HOT 2
- Size Aware Eviction: First-In-First-Out, or evicting largest items first? HOT 2
- Latest triomphe update breaks MSRV
- The `once_cell` dependency should be optional
- Update Key With One Evaluation of the `init` Future HOT 12
- Feature Request: Alternative compute API that skips if other thread/async task is already computing for the key
- Locking `triomphe` is the wrong approach to preserving MSRV HOT 2
- CI: Run Linux arm64 tests only once a week on `arm1.small` instance at AWS CodeBuild
- Use SIEVE as underlying LRU?
- Unexpected behavior with LRU HOT 1
- Support TTL and TTI jitter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moka.