[][src]Struct actix_storage_hashmap::HashMapActor

pub struct HashMapActor { /* fields omitted */ }

An implementation of ExpiryStore based on async actix actors and HashMap

It relies on tokio's DelayQueue internally to manage expiration, and it doesn't have any lock as it runs in single threaded async arbiter.

Example

use actix_storage::Storage;
use actix_storage_hashmap::HashMapActor;
use actix_web::{App, HttpServer};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    let store = HashMapActor::start_default();
    // OR
    let store = HashMapActor::with_capacity(100).start();

    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

impl HashMapActor[src]

#[must_use = "Actor should be started to work by calling `start`"]pub fn new() -> Self[src]

Makes a new HashMapActor without starting it

#[must_use = "Actor should be started to work by calling `start`"]pub fn with_capacity(capacity: usize) -> Self[src]

Makes a new HashMapActor with specified HashMap capacity without starting it

#[must_use = "Actor should be started to work by calling `start`"]pub fn with_capacity_and_channel_size(
    capacity: usize,
    input_buffer: usize,
    output_buffer: usize
) -> Self
[src]

Makes a new HashMapActor with specified HashMap and channel capacity without starting it

Buffer sizes are used for internal expiry channel provider, input is for the channel providing commands expire/extend/expiry/persist and output is the other channel that sends back expired items.

pub fn start(self) -> Addr<Self>[src]

Equivalent of actix::Actor::start for when actix::Actor is not in scope

pub fn start_default() -> Addr<Self>[src]

Equivalent of actix::Actor::start_default for when actix::Actor is not in scope

Trait Implementations

impl Actor for HashMapActor[src]

type Context = Context<Self>

Actor execution context type

impl Debug for HashMapActor[src]

impl Default for HashMapActor[src]

impl Handler<ExpiryRequest> for HashMapActor[src]

type Result = ResponseActFuture<Self, ExpiryResponse>

The type of value that this handler will return. Read more

impl Handler<ExpiryStoreRequest> for HashMapActor[src]

type Result = ResponseActFuture<Self, ExpiryStoreResponse>

The type of value that this handler will return. Read more

impl Handler<StoreRequest> for HashMapActor[src]

type Result = ResponseActFuture<Self, StoreResponse>

The type of value that this handler will return. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,