pub struct CacheManager { /* private fields */ }Expand description
Cache Manager yang mengelola berbagai driver cache (Moka in-memory, Redis, dll).
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub fn new() -> CacheManager
pub fn new() -> CacheManager
Membuat CacheManager baru dengan driver default Moka in-memory.
Sourcepub fn with_driver(default_driver: &str) -> CacheManager
pub fn with_driver(default_driver: &str) -> CacheManager
Membuat CacheManager baru dengan menentukan nama driver default.
Sourcepub fn from_env() -> CacheManager
pub fn from_env() -> CacheManager
Membuat instance CacheManager berdasarkan konfigurasi environment (.env).
Sourcepub fn set_global(cache: Arc<CacheManager>)
pub fn set_global(cache: Arc<CacheManager>)
Daftarkan instance global untuk facade.
Sourcepub fn global() -> Option<Arc<CacheManager>>
pub fn global() -> Option<Arc<CacheManager>>
Dapatkan instance global CacheManager.
Sourcepub fn add_driver(&mut self, name: &str, driver: Arc<dyn CacheDriver>)
pub fn add_driver(&mut self, name: &str, driver: Arc<dyn CacheDriver>)
Daftarkan driver cache baru.
Sourcepub fn driver(&self, name: &str) -> Arc<dyn CacheDriver> ⓘ
pub fn driver(&self, name: &str) -> Arc<dyn CacheDriver> ⓘ
Ambil driver spesifik.
Sourcepub fn default(&self) -> Arc<dyn CacheDriver> ⓘ
pub fn default(&self) -> Arc<dyn CacheDriver> ⓘ
Ambil driver default.
Sourcepub async fn put<T>(&self, key: &str, value: T, ttl_seconds: u64)where
T: Serialize,
pub async fn put<T>(&self, key: &str, value: T, ttl_seconds: u64)where
T: Serialize,
Simpan data ke cache default dengan TTL (Time To Live dalam detik).
Sourcepub async fn get<T>(&self, key: &str) -> Option<T>where
T: DeserializeOwned,
pub async fn get<T>(&self, key: &str) -> Option<T>where
T: DeserializeOwned,
Ambil data dari cache default.
Trait Implementations§
Source§impl Default for CacheManager
impl Default for CacheManager
Source§fn default() -> CacheManager
fn default() -> CacheManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for CacheManager
impl !UnwindSafe for CacheManager
impl Forget for CacheManager
impl Freeze for CacheManager
impl Move for CacheManager
impl Send for CacheManager
impl Sync for CacheManager
impl Unpin for CacheManager
impl UnsafeUnpin for CacheManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().