Cache parsed certificate instead of re-parsing for each field
Use @cached_property decorator to cache the results of parse_certificate(). This significantly cuts down on the number of times certs need to be parsed for a list view.
This commit is contained in:
parent
6ce044806b
commit
ce6e64bd17
|
@ -23,6 +23,8 @@ from sqlalchemy import event, Integer, ForeignKey, String, PassiveDefault, func,
|
||||||
from sqlalchemy_utils.types.arrow import ArrowType
|
from sqlalchemy_utils.types.arrow import ArrowType
|
||||||
from werkzeug.utils import cached_property
|
from werkzeug.utils import cached_property
|
||||||
|
|
||||||
|
import lemur.common.utils
|
||||||
|
|
||||||
from lemur.database import db
|
from lemur.database import db
|
||||||
from lemur.extensions import sentry
|
from lemur.extensions import sentry
|
||||||
|
|
||||||
|
@ -186,7 +188,7 @@ class Certificate(db.Model):
|
||||||
@cached_property
|
@cached_property
|
||||||
def parsed_cert(self):
|
def parsed_cert(self):
|
||||||
assert self.body, "Certificate body not set"
|
assert self.body, "Certificate body not set"
|
||||||
return utils.parse_certificate(self.body)
|
return lemur.common.utils.parse_certificate(self.body)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def active(self):
|
def active(self):
|
||||||
|
|
Loading…
Reference in New Issue