mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
schema: Cache schema in api instance
To avoid generating schema for every schema command call store schema in api instance when first generated and reuse it in next calls. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
committed by
Jan Cholasta
parent
4b97cabb52
commit
d0e708cba2
@@ -729,7 +729,7 @@ class schema(Command):
|
|||||||
|
|
||||||
return fingerprint.hexdigest()[:8]
|
return fingerprint.hexdigest()[:8]
|
||||||
|
|
||||||
def execute(self, *args, **kwargs):
|
def _generate_schema(self, **kwargs):
|
||||||
commands = list(self.api.Object.command.search(**kwargs))
|
commands = list(self.api.Object.command.search(**kwargs))
|
||||||
for command in commands:
|
for command in commands:
|
||||||
name = command['name']
|
name = command['name']
|
||||||
@@ -750,9 +750,17 @@ class schema(Command):
|
|||||||
schema['commands'] = commands
|
schema['commands'] = commands
|
||||||
schema['classes'] = classes
|
schema['classes'] = classes
|
||||||
schema['topics'] = topics
|
schema['topics'] = topics
|
||||||
|
schema['fingerprint'] = self._calculate_fingerprint(schema)
|
||||||
|
|
||||||
|
return schema
|
||||||
|
|
||||||
|
def execute(self, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
schema = self.api._schema
|
||||||
|
except AttributeError:
|
||||||
|
schema = self._generate_schema(**kwargs)
|
||||||
|
setattr(self.api, '_schema', schema)
|
||||||
|
|
||||||
schema_fp = self._calculate_fingerprint(schema)
|
|
||||||
schema['fingerprint'] = schema_fp
|
|
||||||
schema['ttl'] = SCHEMA_TTL
|
schema['ttl'] = SCHEMA_TTL
|
||||||
|
|
||||||
if schema['fingerprint'] in kwargs.get('known_fingerprints', []):
|
if schema['fingerprint'] in kwargs.get('known_fingerprints', []):
|
||||||
|
|||||||
Reference in New Issue
Block a user