pub struct HashMapStore { /* private fields */ }Expand description
A simple implementation of Store based on RwLock wrapped HashMap
This provider doesn’t support key expiration thus Storage will return errors when trying to use methods that require expiration functionality.
§Example
use actix_storage::Storage;
use actix_storage_hashmap::HashMapStore;
use actix_web::{App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let storage = Storage::build().store(HashMapStore::new()).finish();
let server = HttpServer::new(move || {
App::new()
.data(storage.clone())
});
server.bind("localhost:5000")?.run().await
}Implementations§
Source§impl HashMapStore
impl HashMapStore
Trait Implementations§
Source§impl Debug for HashMapStore
impl Debug for HashMapStore
Source§impl Default for HashMapStore
impl Default for HashMapStore
Source§fn default() -> HashMapStore
fn default() -> HashMapStore
Returns the “default value” for a type. Read more
Source§impl Store for HashMapStore
impl Store for HashMapStore
Source§fn set<'life0, 'async_trait>(
&'life0 self,
scope: Arc<[u8]>,
key: Arc<[u8]>,
value: Arc<[u8]>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set<'life0, 'async_trait>(
&'life0 self,
scope: Arc<[u8]>,
key: Arc<[u8]>,
value: Arc<[u8]>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set a key-value pair, if the key already exist, value should be overwritten
Source§fn get<'life0, 'async_trait>(
&'life0 self,
scope: Arc<[u8]>,
key: Arc<[u8]>,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<[u8]>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
scope: Arc<[u8]>,
key: Arc<[u8]>,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<[u8]>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a value for specified key, it should result in None if the value does not exist
Auto Trait Implementations§
impl !Freeze for HashMapStore
impl RefUnwindSafe for HashMapStore
impl Send for HashMapStore
impl Sync for HashMapStore
impl Unpin for HashMapStore
impl UnwindSafe for HashMapStore
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