@@ -9,48 +9,57 @@ class CacheKey(namedtuple("CacheKey", ["key", "expiration"])):
99 pass
1010
1111
12- def for_repository_blob (namespace_name , repo_name , digest , version ):
12+ def for_repository_blob (namespace_name , repo_name , digest , version , cache_config ):
1313 """
1414 Returns a cache key for a blob in a repository.
1515 """
16- return CacheKey ("repo_blob__%s_%s_%s_%s" % (namespace_name , repo_name , digest , version ), "60s" )
16+ cache_ttl = cache_config .get ("repository_blob_cache_ttl" , "60s" )
17+ return CacheKey (
18+ "repo_blob__%s_%s_%s_%s" % (namespace_name , repo_name , digest , version ), cache_ttl
19+ )
1720
1821
19- def for_catalog_page (auth_context_key , start_id , limit ):
22+ def for_catalog_page (auth_context_key , start_id , limit , cache_config ):
2023 """
2124 Returns a cache key for a single page of a catalog lookup for an authed context.
2225 """
2326 params = (auth_context_key or "(anon)" , start_id or 0 , limit or 0 )
24- return CacheKey ("catalog_page__%s_%s_%s" % params , "60s" )
27+ cache_ttl = cache_config .get ("catalog_page_cache_ttl" , "60s" )
28+ return CacheKey ("catalog_page__%s_%s_%s" % params , cache_ttl )
2529
2630
27- def for_namespace_geo_restrictions (namespace_name ):
31+ def for_namespace_geo_restrictions (namespace_name , cache_config ):
2832 """
2933 Returns a cache key for the geo restrictions for a namespace.
3034 """
31- return CacheKey ("geo_restrictions__%s" % (namespace_name ), "240s" )
35+ cache_ttl = cache_config .get ("namespace_geo_restrictions_cache_ttl" , "240s" )
36+ return CacheKey ("geo_restrictions__%s" % namespace_name , cache_ttl )
3237
3338
34- def for_active_repo_tags (repository_id , start_pagination_id , limit ):
39+ def for_active_repo_tags (repository_id , start_pagination_id , limit , cache_config ):
3540 """
3641 Returns a cache key for the active tags in a repository.
3742 """
43+
44+ cache_ttl = cache_config .get ("active_repo_tags_cache_ttl" , "120s" )
3845 return CacheKey (
39- "repo_active_tags__%s_%s_%s" % (repository_id , start_pagination_id , limit ), "120s"
46+ "repo_active_tags__%s_%s_%s" % (repository_id , start_pagination_id , limit ), cache_ttl
4047 )
4148
4249
43- def for_appr_applications_list (namespace , limit ):
50+ def for_appr_applications_list (namespace , limit , cache_config ):
4451 """
4552 Returns a cache key for listing applications under the App Registry.
4653 """
47- return CacheKey ("appr_applications_list_%s_%s" % (namespace , limit ), "3600s" )
54+ cache_ttl = cache_config .get ("appr_applications_list_cache_ttl" , "3600s" )
55+ return CacheKey ("appr_applications_list_%s_%s" % (namespace , limit ), cache_ttl )
4856
4957
50- def for_appr_show_package (namespace , package_name , release , media_type ):
58+ def for_appr_show_package (namespace , package_name , release , media_type , cache_config ):
5159 """
5260 Returns a cache key for showing a package under the App Registry.
5361 """
62+ cache_ttl = cache_config .get ("appr_show_package_cache_ttl" , "3600s" )
5463 return CacheKey (
55- "appr_show_package_%s_%s_%s-%s" % (namespace , package_name , release , media_type ), "3600s"
64+ "appr_show_package_%s_%s_%s-%s" % (namespace , package_name , release , media_type ), cache_ttl
5665 )
0 commit comments