Working on issue #981 - Improved LDAP sync performan by caching entry count result.

This commit is contained in:
Thorsten Eckel 2017-05-10 09:53:03 +02:00
parent e3891ebeed
commit 508f621377

View file

@ -51,18 +51,21 @@ module Import
def self.pre_import_hook(_records, *_args) def self.pre_import_hook(_records, *_args)
super super
add_sum_to_statistics
end
#cache_key = "#{@ldap.host}::#{@ldap.port}::#{@ldap.ssl}::#{@ldap.base_dn}" def self.add_sum_to_statistics
#if !@dry_run cache_key = "#{@ldap.host}::#{@ldap.port}::#{@ldap.ssl}::#{@ldap.base_dn}::#{@config[:user_filter]}"
# sum = Cache.get(cache_key) if !@dry_run
#end sum = Cache.get(cache_key)
end
sum ||= @ldap.count(@config[:user_filter]) sum ||= @ldap.count(@config[:user_filter])
@statistics[:sum] = sum @statistics[:sum] = sum
return if !@dry_run return if !@dry_run
#Cache.write(cache_key, sum, { expires_in: 1.hour }) Cache.write(cache_key, sum, { expires_in: 1.hour })
end end
def self.add_to_statistics(backend_instance) def self.add_to_statistics(backend_instance)