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:
Joseph Schorr 2018-06-19 13:27:16 -04:00
parent a1c06042c6
commit 2caaf84f31
4 changed files with 53 additions and 10 deletions

View file

@ -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 = {}