Replace individual cache instantiations with all at once.
This commit is contained in:
parent
96d79f2b25
commit
db28b6819c
1 changed files with 7 additions and 17 deletions
|
@ -35,7 +35,6 @@ logging.basicConfig()
|
||||||
class PDBAlbumMixin:
|
class PDBAlbumMixin:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._album_cache = cacheclass.Cache()
|
|
||||||
|
|
||||||
def get_album(self, id=None, path=None):
|
def get_album(self, id=None, path=None):
|
||||||
if not helpers.is_xor(id, path):
|
if not helpers.is_xor(id, path):
|
||||||
|
@ -125,7 +124,6 @@ class PDBAlbumMixin:
|
||||||
class PDBBookmarkMixin:
|
class PDBBookmarkMixin:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._bookmark_cache = cacheclass.Cache()
|
|
||||||
|
|
||||||
def get_bookmark(self, id):
|
def get_bookmark(self, id):
|
||||||
return self.get_thing_by_id('bookmark', id)
|
return self.get_thing_by_id('bookmark', id)
|
||||||
|
@ -163,7 +161,6 @@ class PDBBookmarkMixin:
|
||||||
class PDBPhotoMixin:
|
class PDBPhotoMixin:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._photo_cache = cacheclass.Cache()
|
|
||||||
|
|
||||||
def _assert_no_such_photo(self, filepath):
|
def _assert_no_such_photo(self, filepath):
|
||||||
try:
|
try:
|
||||||
|
@ -786,7 +783,6 @@ class PDBSQLMixin:
|
||||||
class PDBTagMixin:
|
class PDBTagMixin:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._tag_cache = cacheclass.Cache()
|
|
||||||
|
|
||||||
def _assert_no_such_tag(self, tagname):
|
def _assert_no_such_tag(self, tagname):
|
||||||
try:
|
try:
|
||||||
|
@ -848,10 +844,10 @@ class PDBTagMixin:
|
||||||
tagname = name_row[0]
|
tagname = name_row[0]
|
||||||
|
|
||||||
tag_id = tag_row[constants.SQL_INDEX['tags']['id']]
|
tag_id = tag_row[constants.SQL_INDEX['tags']['id']]
|
||||||
tag = self._tag_cache.get(tag_id, fallback=None)
|
tag = self.caches['tag'].get(tag_id, fallback=None)
|
||||||
if tag is None:
|
if tag is None:
|
||||||
tag = objects.Tag(self, tag_row)
|
tag = objects.Tag(self, tag_row)
|
||||||
self._tag_cache[tag_id] = tag
|
self.caches['tag'][tag_id] = tag
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
def get_tags(self):
|
def get_tags(self):
|
||||||
|
@ -905,7 +901,6 @@ class PDBTagMixin:
|
||||||
class PDBUserMixin:
|
class PDBUserMixin:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._user_cache = cacheclass.Cache()
|
|
||||||
|
|
||||||
def _assert_no_such_user(self, username):
|
def _assert_no_such_user(self, username):
|
||||||
try:
|
try:
|
||||||
|
@ -1332,17 +1327,12 @@ class PhotoDB(
|
||||||
self._cached_frozen_children = None
|
self._cached_frozen_children = None
|
||||||
self._cached_qualname_map = None
|
self._cached_qualname_map = None
|
||||||
|
|
||||||
self._album_cache.maxlen = self.config['cache_size']['album']
|
|
||||||
self._bookmark_cache.maxlen = self.config['cache_size']['bookmark']
|
|
||||||
self._photo_cache.maxlen = self.config['cache_size']['photo']
|
|
||||||
self._tag_cache.maxlen = self.config['cache_size']['tag']
|
|
||||||
self._user_cache.maxlen = self.config['cache_size']['user']
|
|
||||||
self.caches = {
|
self.caches = {
|
||||||
'album': self._album_cache,
|
'album': cacheclass.Cache(maxlen=self.config['cache_size']['album']),
|
||||||
'bookmark': self._bookmark_cache,
|
'bookmark': cacheclass.Cache(maxlen=self.config['cache_size']['bookmark']),
|
||||||
'photo': self._photo_cache,
|
'photo': cacheclass.Cache(maxlen=self.config['cache_size']['photo']),
|
||||||
'tag': self._tag_cache,
|
'tag': cacheclass.Cache(maxlen=self.config['cache_size']['tag']),
|
||||||
'user': self._user_cache,
|
'user': cacheclass.Cache(maxlen=self.config['cache_size']['user']),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _check_version(self):
|
def _check_version(self):
|
||||||
|
|
Loading…
Reference in a new issue