pub struct CachingAspect { /* private fields */ }Expand description
Generic caching aspect with TTL support.
§Example
ⓘ
use aspect_std::CachingAspect;
use aspect_macros::aspect;
use std::time::Duration;
let cache = CachingAspect::new().with_ttl(Duration::from_secs(60));
#[aspect(cache.clone())]
fn expensive_query(id: u64) -> Result<String, String> {
// Expensive operation - will be cached
Ok(format!("Result for {}", id))
}Implementations§
Trait Implementations§
Source§impl Aspect for CachingAspect
impl Aspect for CachingAspect
Source§fn around(
&self,
pjp: ProceedingJoinPoint<'_>,
) -> Result<Box<dyn Any>, AspectError>
fn around( &self, pjp: ProceedingJoinPoint<'_>, ) -> Result<Box<dyn Any>, AspectError>
Advice that wraps the entire target function execution. Read more
Source§fn after(&self, _ctx: &JoinPoint, _result: &(dyn Any + 'static))
fn after(&self, _ctx: &JoinPoint, _result: &(dyn Any + 'static))
Advice executed after the target function completes successfully. Read more
Source§fn after_error(&self, _ctx: &JoinPoint, _error: &AspectError)
fn after_error(&self, _ctx: &JoinPoint, _error: &AspectError)
Advice executed when the target function encounters an error. Read more
Source§impl Clone for CachingAspect
impl Clone for CachingAspect
Source§fn clone(&self) -> CachingAspect
fn clone(&self) -> CachingAspect
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 moreAuto Trait Implementations§
impl Freeze for CachingAspect
impl RefUnwindSafe for CachingAspect
impl Send for CachingAspect
impl Sync for CachingAspect
impl Unpin for CachingAspect
impl UnsafeUnpin for CachingAspect
impl UnwindSafe for CachingAspect
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