pub struct CacheActor<B>where
B: Backend,{ /* private fields */ }Expand description
Actix actor implements cache logic.
This actor implement only Handler<QueryCache>.
Where QueryCache - Actix message with two fields:
- Generic actix message for sending to upstream actor.
- Address of upstream actor
§Example
use actix::prelude::*;
use hitbox_actix::{Cache, RedisBackend, CacheError};
#[actix_rt::main]
async fn main() -> Result<(), CacheError> {
let cache = Cache::new().await?.start();
Ok(())
}Implementations§
Source§impl<B> CacheActor<B>where
B: Actor + Backend,
<B as Actor>::Context: ToEnvelope<B, Get> + ToEnvelope<B, Set> + ToEnvelope<B, Lock> + ToEnvelope<B, Delete>,
impl<B> CacheActor<B>where
B: Actor + Backend,
<B as Actor>::Context: ToEnvelope<B, Get> + ToEnvelope<B, Set> + ToEnvelope<B, Lock> + ToEnvelope<B, Delete>,
Sourcepub async fn new() -> Result<CacheActor<RedisBackend>, CacheError>
pub async fn new() -> Result<CacheActor<RedisBackend>, CacheError>
Initialize new Cache actor with default hitbox_redis::RedisBackend.
Sourcepub fn builder() -> CacheBuilder<B>
pub fn builder() -> CacheBuilder<B>
Creates new CacheBuilder instance for Cache actor configuration.
Trait Implementations§
Source§impl<B> Actor for CacheActor<B>where
B: Backend,
impl<B> Actor for CacheActor<B>where
B: Backend,
Source§type Context = Context<CacheActor<B>>
type Context = Context<CacheActor<B>>
Actor execution context type
Source§fn stopping(&mut self, ctx: &mut Self::Context) -> Running
fn stopping(&mut self, ctx: &mut Self::Context) -> Running
Called after an actor is in
Actor::Stopping state. Read moreSource§fn start_in_arbiter<F>(arb: &Arbiter, f: F) -> Addr<Self>
fn start_in_arbiter<F>(arb: &Arbiter, f: F) -> Addr<Self>
Start new actor in arbiter’s thread.
Source§impl<'a, A, M, B> Handler<QueryCache<A, M>> for CacheActor<B>where
B: Actor + Backend,
<B as Actor>::Context: ToEnvelope<B, Get> + ToEnvelope<B, Set> + ToEnvelope<B, Lock> + ToEnvelope<B, Delete>,
A: Actor + Handler<M> + Send,
M: Message + Cacheable + Send + 'static,
M::Result: MessageResponse<A, M> + CacheableResponse + Debug + Send,
<<M as Message>::Result as CacheableResponse>::Cached: Serialize + DeserializeOwned,
<A as Actor>::Context: ToEnvelope<A, M>,
impl<'a, A, M, B> Handler<QueryCache<A, M>> for CacheActor<B>where
B: Actor + Backend,
<B as Actor>::Context: ToEnvelope<B, Get> + ToEnvelope<B, Set> + ToEnvelope<B, Lock> + ToEnvelope<B, Delete>,
A: Actor + Handler<M> + Send,
M: Message + Cacheable + Send + 'static,
M::Result: MessageResponse<A, M> + CacheableResponse + Debug + Send,
<<M as Message>::Result as CacheableResponse>::Cached: Serialize + DeserializeOwned,
<A as Actor>::Context: ToEnvelope<A, M>,
Auto Trait Implementations§
impl<B> Freeze for CacheActor<B>
impl<B> !RefUnwindSafe for CacheActor<B>
impl<B> Send for CacheActor<B>
impl<B> Sync for CacheActor<B>
impl<B> Unpin for CacheActor<B>
impl<B> !UnwindSafe for CacheActor<B>
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