perf(core): cache the schema of LDAP user sources
parent
debcbd16db
commit
d0056d3b27
|
@ -440,6 +440,8 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
|
||||||
- (NGLdapConnection *) _ldapConnection
|
- (NGLdapConnection *) _ldapConnection
|
||||||
{
|
{
|
||||||
NGLdapConnection *ldapConnection;
|
NGLdapConnection *ldapConnection;
|
||||||
|
NSString *value, *key;
|
||||||
|
SOGoCache *cache;
|
||||||
|
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
|
@ -459,7 +461,20 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
|
||||||
if (!_schema)
|
if (!_schema)
|
||||||
{
|
{
|
||||||
_schema = [LDAPSourceSchema new];
|
_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
|
else
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
/* LDAPSourceSchema.h - this file is part of SOGo
|
/* LDAPSourceSchema.h - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Inverse inc
|
* Copyright (C) 2011-2021 Inverse inc
|
||||||
*
|
|
||||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* This file is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -34,11 +32,15 @@
|
||||||
|
|
||||||
- (void) readSchemaFromConnection: (NGLdapConnection *) conn;
|
- (void) readSchemaFromConnection: (NGLdapConnection *) conn;
|
||||||
|
|
||||||
|
- (void) setSchema: (NSMutableDictionary *) newSchema;
|
||||||
|
|
||||||
- (NSArray *) fieldsForClass: (NSString *) className;
|
- (NSArray *) fieldsForClass: (NSString *) className;
|
||||||
|
|
||||||
/* merged list of attributes with unique names */
|
/* merged list of attributes with unique names */
|
||||||
- (NSArray *) fieldsForClasses: (NSArray *) className;
|
- (NSArray *) fieldsForClasses: (NSArray *) className;
|
||||||
|
|
||||||
|
- (NSString *) jsonRepresentation;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif /* LDAPSOURCESCHEMA_H */
|
#endif /* LDAPSOURCESCHEMA_H */
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
/* LDAPSourceSchema.m - this file is part of SOGo
|
/* LDAPSourceSchema.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Inverse inc
|
* Copyright (C) 2011-2021 Inverse inc
|
||||||
*
|
|
||||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* This file is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -239,6 +237,12 @@ fillSchemaFromEntry (NSMutableDictionary *schema, NGLdapEntry *entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setSchema: (NSMutableDictionary *) newSchema
|
||||||
|
{
|
||||||
|
ASSIGN (schema, newSchema);
|
||||||
|
[schema release];
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fillFieldsForClass (NSMutableDictionary *schema, NSString *schemaName,
|
fillFieldsForClass (NSMutableDictionary *schema, NSString *schemaName,
|
||||||
NSMutableArray *fields)
|
NSMutableArray *fields)
|
||||||
|
@ -289,4 +293,9 @@ fillFieldsForClass (NSMutableDictionary *schema, NSString *schemaName,
|
||||||
return [fieldHash allKeys];
|
return [fieldHash allKeys];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *) jsonRepresentation
|
||||||
|
{
|
||||||
|
return [schema jsonRepresentation];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue