perf(core): cache the schema of LDAP user sources

This commit is contained in:
Francis Lachapelle committed 2021-05-14 11:56:13 -04:00
1 parent debcbd16db
commit d0056d3b27
3 files changed
+33 -7

No files matched your search

+16 -1
View File
@@ -440,6 +440,8 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
- (NGLdapConnection *) _ldapConnection
{
NGLdapConnection *ldapConnection;
NSString *value, *key;
SOGoCache *cache;
NS_DURING
{
@@ -459,7 +461,20 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
if (!_schema)
{
_schema = [LDAPSourceSchema new];
[_schema readSchemaFromConnection: ldapConnection];
cache = [SOGoCache sharedCache];
key = [NSString stringWithFormat: @"schema:%@", _sourceID];
value = [cache valueForKey: key];
if (value)
{
[_schema setSchema: (NSMutableDictionary *)[value objectFromJSONString]];
}
else
{
// We go check in the LDAP directory
[_schema readSchemaFromConnection: ldapConnection];
[cache setValue: [_schema jsonRepresentation] forKey: key];
}
}
}
else