pub struct BanditCache { /* private fields */ }
Implementations§
source§impl BanditCache
impl BanditCache
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty BanditCache
.
The cache is initialized as an empty HashMap
and is used to store
precomputed Beta distribution parameters for faster access during
Thompson Sampling operations.
sourcepub fn get_beta_distribution(
&mut self,
bandit: &str,
arm: &str,
db: &RelevancyDb,
) -> Result<(u64, u64)>
pub fn get_beta_distribution( &mut self, bandit: &str, arm: &str, db: &RelevancyDb, ) -> Result<(u64, u64)>
Retrieves the Beta distribution parameters for a given bandit and arm.
If the parameters for the specified bandit
and arm
are already cached,
they are returned directly. Otherwise, the parameters are fetched from
the database, added to the cache, and then returned.
Trait Implementations§
source§impl Default for BanditCache
impl Default for BanditCache
source§fn default() -> BanditCache
fn default() -> BanditCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BanditCache
impl RefUnwindSafe for BanditCache
impl Send for BanditCache
impl Sync for BanditCache
impl Unpin for BanditCache
impl UnwindSafe for BanditCache
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
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>
Read more