Struct FusionCacheBuilder

Source
pub struct FusionCacheBuilder<TKey: Hash + Eq + Send + Sync + Clone + Serialize + DeserializeOwned + 'static, TValue: Clone + Send + Sync + Serialize + DeserializeOwned + 'static> { /* private fields */ }

Implementations§

Source§

impl<TKey: Hash + Eq + Send + Sync + Clone + Serialize + DeserializeOwned + Debug + 'static, TValue: Clone + Send + Sync + Serialize + DeserializeOwned + Debug + 'static> FusionCacheBuilder<TKey, TValue>

Source

pub fn new() -> Self

Source

pub fn with_capacity(self, capacity: u64) -> Self

Sets the maximum capacity of the cache. This is the maximum number of entries the cache can hold before it starts evicting old entries. The default capacity is 1000 entries.

§Arguments
  • capacity - The maximum number of entries the cache can hold
Source

pub fn with_time_to_live(self, time_to_live: Duration) -> Self

Sets the time-to-live for entries in the cache.

§Arguments
  • time_to_live - The time-to-live for entries in the cache
Source

pub fn with_time_to_idle(self, time_to_idle: Duration) -> Self

Sets the time-to-idle for entries in the cache.

§Arguments
  • time_to_idle - The time-to-idle for entries in the cache
Source

pub fn with_fail_safe( self, entry_ttl: Duration, failsafe_cycle_ttl: Duration, max_cycles: Option<u64>, soft_timeout: Option<Duration>, ) -> Self

Configures the fail-safe mechanism for the cache. This allows the cache to handle situations where the factory is slow or fails to respond.

§Arguments
  • entry_ttl - The time-to-live for entries in the fail-safe cache
  • failsafe_cycle_ttl - The time-to-live for a fail-safe cycle
  • max_cycles - The maximum number of cycles the fail-safe cache can go through before giving up
  • soft_timeout - An optional soft timeout for factory operations, after which the cache will try to use the fail-safe cache
Source

pub fn with_hard_timeout(self, timeout: Duration) -> Self

Sets a hard timeout for factory operations. If the factory does not return a value within this duration, it will return a FusionCacheError::FactoryTimeout.

§Arguments
  • timeout - The maximum duration to wait for the factory to return a value
Source

pub fn set_factory_background_execution( self, should_execute_in_background: bool, ) -> Self

Configures whether the factory should execute in the background after a soft timeout. If set to true, the factory will continue to run in the background even after a soft timeout.

§Arguments
  • should_execute_in_background - Whether the factory should execute in the background
Source

pub fn with_redis( self, address: String, application_name: String, should_writes_happen_in_background: bool, entry_ttl: Option<Duration>, ) -> Self

Configures Redis as a level 2 cache. If use_as_distributed_cache is true, it will also be used as a distributed cache, that is, Redis will also be used as a backplane for the cache.

§Arguments
  • address - The address of the Redis server.
  • application_name - The name of the application.
  • should_writes_happen_in_background - Whether the writes to Redis should happen in the background.
  • entry_ttl - The time-to-live for entries in the Redis cache.
Source

pub async fn build(self) -> Result<FusionCache<TKey, TValue>, FusionCacheError>

Auto Trait Implementations§

§

impl<TKey, TValue> Freeze for FusionCacheBuilder<TKey, TValue>

§

impl<TKey, TValue> RefUnwindSafe for FusionCacheBuilder<TKey, TValue>
where TKey: RefUnwindSafe, TValue: RefUnwindSafe,

§

impl<TKey, TValue> Send for FusionCacheBuilder<TKey, TValue>

§

impl<TKey, TValue> Sync for FusionCacheBuilder<TKey, TValue>

§

impl<TKey, TValue> Unpin for FusionCacheBuilder<TKey, TValue>
where TKey: Unpin, TValue: Unpin,

§

impl<TKey, TValue> UnwindSafe for FusionCacheBuilder<TKey, TValue>
where TKey: UnwindSafe, TValue: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,