pub struct DashMapActor { /* private fields */ }Expand description
An implementation of ExpiryStore based on sync
actix actors and HashMap
It relies on delay_queue crate to provide expiration.
§Example
use actix_storage::Storage;
use actix_storage_dashmap::DashMapActor;
use actix_web::{App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
const THREADS_NUMBER: usize = 4;
let store = DashMapActor::start_default(THREADS_NUMBER);
// OR
let store = DashMapActor::with_capacity(100).start(THREADS_NUMBER);
let storage = Storage::build().expiry_store(store).finish();
let server = HttpServer::new(move || {
App::new()
.data(storage.clone())
});
server.bind("localhost:5000")?.run().await
}requires [“actor”] feature
Implementations§
Source§impl DashMapActor
impl DashMapActor
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Makes a new DashMapActor with specified DashMap capacity without starting it
Sourcepub fn start_default(threads_num: usize) -> Addr<Self>
pub fn start_default(threads_num: usize) -> Addr<Self>
Create default actor and start the actor in an actix sync arbiter with specified number of threads
Trait Implementations§
Source§impl Actor for DashMapActor
impl Actor for DashMapActor
Source§impl Clone for DashMapActor
impl Clone for DashMapActor
Source§fn clone(&self) -> DashMapActor
fn clone(&self) -> DashMapActor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for DashMapActor
impl Default for DashMapActor
Source§fn default() -> DashMapActor
fn default() -> DashMapActor
Returns the “default value” for a type. Read more
Source§impl Handler<ExpiryRequest> for DashMapActor
impl Handler<ExpiryRequest> for DashMapActor
Source§impl Handler<ExpiryStoreRequest> for DashMapActor
impl Handler<ExpiryStoreRequest> for DashMapActor
Source§impl Handler<StoreRequest> for DashMapActor
impl Handler<StoreRequest> for DashMapActor
Auto Trait Implementations§
impl Freeze for DashMapActor
impl !RefUnwindSafe for DashMapActor
impl Send for DashMapActor
impl Sync for DashMapActor
impl Unpin for DashMapActor
impl !UnwindSafe for DashMapActor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more