Let get_tag_by_name use cache after finding the ID.
This commit is contained in:
parent
ac41598bb0
commit
abe82dde9e
1 changed files with 9 additions and 1 deletions
|
@ -811,11 +811,12 @@ class PDBTagMixin:
|
||||||
except (exceptions.TagTooShort, exceptions.TagTooLong):
|
except (exceptions.TagTooShort, exceptions.TagTooLong):
|
||||||
raise exceptions.NoSuchTag(tagname)
|
raise exceptions.NoSuchTag(tagname)
|
||||||
|
|
||||||
|
tag_row = None
|
||||||
while True:
|
while True:
|
||||||
# Return if it's a toplevel...
|
# Return if it's a toplevel...
|
||||||
tag_row = self.sql_select_one('SELECT * FROM tags WHERE name == ?', [tagname])
|
tag_row = self.sql_select_one('SELECT * FROM tags WHERE name == ?', [tagname])
|
||||||
if tag_row is not None:
|
if tag_row is not None:
|
||||||
return objects.Tag(self, tag_row)
|
break
|
||||||
|
|
||||||
# ...or resolve the synonym and try again.
|
# ...or resolve the synonym and try again.
|
||||||
query = 'SELECT mastername FROM tag_synonyms WHERE name == ?'
|
query = 'SELECT mastername FROM tag_synonyms WHERE name == ?'
|
||||||
|
@ -826,6 +827,13 @@ class PDBTagMixin:
|
||||||
raise exceptions.NoSuchTag(tagname)
|
raise exceptions.NoSuchTag(tagname)
|
||||||
tagname = name_row[0]
|
tagname = name_row[0]
|
||||||
|
|
||||||
|
tag_id = tag_row[constants.SQL_INDEX['tags']['id']]
|
||||||
|
tag = self._tag_cache.get(tag_id, fallback=None)
|
||||||
|
if tag is None:
|
||||||
|
tag = objects.Tag(self, tag_row)
|
||||||
|
self._tag_cache[tag_id] = tag
|
||||||
|
return tag
|
||||||
|
|
||||||
def get_tags(self):
|
def get_tags(self):
|
||||||
'''
|
'''
|
||||||
Yield all Tags in the database.
|
Yield all Tags in the database.
|
||||||
|
|
Loading…
Reference in a new issue