Add caching support to catalog
We will now cache the results of the catalog for 60s and not hit the database at all if cached
This commit is contained in:
parent
a1c06042c6
commit
2caaf84f31
4 changed files with 53 additions and 10 deletions
|
@ -390,7 +390,7 @@ class V2Protocol(RegistryProtocol):
|
|||
return results
|
||||
|
||||
def catalog(self, session, page_size=2, credentials=None, options=None, expected_failure=None,
|
||||
namespace=None, repo_name=None):
|
||||
namespace=None, repo_name=None, bearer_token=None):
|
||||
options = options or ProtocolOptions()
|
||||
scopes = options.scopes or []
|
||||
|
||||
|
@ -409,6 +409,11 @@ class V2Protocol(RegistryProtocol):
|
|||
'Authorization': 'Bearer ' + token,
|
||||
}
|
||||
|
||||
if bearer_token is not None:
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + bearer_token,
|
||||
}
|
||||
|
||||
results = []
|
||||
url = '/v2/_catalog'
|
||||
params = {}
|
||||
|
|
Reference in a new issue