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 minimal_flag_called_events(&self) -> bool
pub fn minimal_flag_called_events(&self) -> bool
Whether the most recent definitions poll enabled minimal
$feature_flag_called events. false until definitions load, so a
missing signal always yields full events.
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).