1010from wireup import Inject , service
1111
1212from eligibility_signposting_api .model .campaign_config import CampaignConfig , Rules
13- from eligibility_signposting_api .config .constants import ttl
13+ from eligibility_signposting_api .config .constants import TTL , RESERVED_TEST_CONSUMER_IDS
1414
1515BucketName = NewType ("BucketName" , str )
1616
@@ -32,14 +32,14 @@ def __init__(
3232 self .bucket_name = bucket_name
3333 self ._campaign_configs_cache : list [CampaignConfig ] | None = None
3434 self ._cache_expiry_epoch : float = 0.0
35- self ._cache_ttl_seconds : int = int (ttl .get (os .getenv ("ENVIRONMENT" ), 0 ))
35+ self ._cache_ttl_seconds : int = int (TTL .get (os .getenv ("ENVIRONMENT" ), 0 ))
3636
37- def get_campaign_configs (self , bypass_cache : bool = False ) -> Generator [CampaignConfig , None , None ]:
37+ def get_campaign_configs (self , consumer_id : str ) -> Generator [CampaignConfig , None , None ]:
3838 now = time .time ()
3939 cache_enabled = self ._cache_ttl_seconds > 0
4040 cache_valid = (
4141 cache_enabled
42- and not bypass_cache
42+ and consumer_id not in RESERVED_TEST_CONSUMER_IDS
4343 and self ._campaign_configs_cache is not None
4444 and now < self ._cache_expiry_epoch
4545 )
@@ -51,13 +51,13 @@ def get_campaign_configs(self, bypass_cache: bool = False) -> Generator[Campaign
5151 return
5252
5353 logger .info (
54- "Refreshing campaign configs from S3 (bypass_cache =%s, ttl_seconds=%s)" ,
55- bypass_cache ,
54+ "Refreshing campaign configs from S3 (consumer_id =%s, ttl_seconds=%s)" ,
55+ consumer_id ,
5656 self ._cache_ttl_seconds ,
5757 )
5858 campaign_configs = self ._load_campaign_configs_from_s3 ()
5959
60- if cache_enabled and not bypass_cache :
60+ if cache_enabled and consumer_id not in RESERVED_TEST_CONSUMER_IDS :
6161 self ._campaign_configs_cache = campaign_configs
6262 self ._cache_expiry_epoch = now + self ._cache_ttl_seconds
6363
0 commit comments