Add the concept of a data model cache, for caching of Namedtuple objects from the data model

Will be used to cache blobs, thus removing the need to hit the database in most blob requests
This commit is contained in:
Joseph Schorr 2017-12-14 13:36:51 -05:00
parent 51e67ab7f5
commit 3c72e9878d
3 changed files with 72 additions and 0 deletions

8
data/cache/cache_key.py vendored Normal file
View file

@ -0,0 +1,8 @@
from collections import namedtuple
class CacheKey(namedtuple('CacheKey', ['key', 'expiration'])):
""" Defines a key into the data model cache. """
pass
def for_repository_blob(namespace_name, repo_name, digest):
return CacheKey('repository_blob:%s:%s:%s' % (namespace_name, repo_name, digest), '60s')