pub struct FlagCache { /* private fields */ }Expand description
Thread-safe cache for feature flag definitions.
Stores feature flags, group type mappings, and cohort definitions that have been fetched from the PostHog API. The cache is shared between the poller (which updates it) and the evaluator (which reads from it).
Implementations§
Source§impl FlagCache
impl FlagCache
Sourcepub fn update(&self, response: LocalEvaluationResponse)
pub fn update(&self, response: LocalEvaluationResponse)
Replace cached flags, group type mappings, and cohorts from a local evaluation API response.
Sourcepub fn get_flag(&self, key: &str) -> Option<FeatureFlag>
pub fn get_flag(&self, key: &str) -> Option<FeatureFlag>
Return a cached feature flag by key.
Sourcepub fn get_all_flags(&self) -> Vec<FeatureFlag>
pub fn get_all_flags(&self) -> Vec<FeatureFlag>
Return all cached feature flag definitions.
Sourcepub fn get_cohort(&self, id: &str) -> Option<Cohort>
pub fn get_cohort(&self, id: &str) -> Option<Cohort>
Return a cached cohort by ID.
Sourcepub fn get_all_cohorts(&self) -> HashMap<String, Cohort>
pub fn get_all_cohorts(&self) -> HashMap<String, Cohort>
Return all cached cohorts, keyed by cohort ID.
Sourcepub fn get_cohort_definitions(&self) -> HashMap<String, CohortDefinition>
pub fn get_cohort_definitions(&self) -> HashMap<String, CohortDefinition>
Get all cohorts as CohortDefinitions for evaluation context
Sourcepub fn get_flags_map(&self) -> HashMap<String, FeatureFlag>
pub fn get_flags_map(&self) -> HashMap<String, FeatureFlag>
Get all flags as a HashMap for evaluation context
Sourcepub fn get_group_type_mapping(&self) -> HashMap<String, String>
pub fn get_group_type_mapping(&self) -> HashMap<String, String>
Get the group type mapping (group type index → group type name).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FlagCache
impl RefUnwindSafe for FlagCache
impl Send for FlagCache
impl Sync for FlagCache
impl Unpin for FlagCache
impl UnsafeUnpin for FlagCache
impl UnwindSafe for FlagCache
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