186 self.base_filters = [filter_format('(%s=%s)', ('objectClass', o)) |
186 self.base_filters = [filter_format('(%s=%s)', ('objectClass', o)) |
187 for o in self.user_classes] |
187 for o in self.user_classes] |
188 self._conn = None |
188 self._conn = None |
189 self._cache = {} |
189 self._cache = {} |
190 # ttlm is in minutes! |
190 # ttlm is in minutes! |
191 ttlm = time_validator(None, None, |
191 self._cache_ttl = time_validator(None, None, |
192 source_config.get('cache-life-time', 2*60*60)) // 60 |
192 source_config.get('cache-life-time', 2*60*60)) |
193 self._query_cache = TimedCache(max(ttlm, 1)) |
193 self._cache_ttl = max(71, self._cache_ttl) |
|
194 self._query_cache = TimedCache(self.cache_ttl) |
194 # interval is in seconds ! |
195 # interval is in seconds ! |
195 self._interval = time_validator(None, None, |
196 self._interval = time_validator(None, None, |
196 source_config.get('synchronization-interval', |
197 source_config.get('synchronization-interval', |
197 24*60*60)) |
198 24*60*60)) |
198 |
199 |
199 def reset_caches(self): |
200 def reset_caches(self): |
200 """method called during test to reset potential source caches""" |
201 """method called during test to reset potential source caches""" |
201 self._cache = {} |
202 self._cache = {} |
202 self._query_cache = TimedCache(2*60) # TimedCache is in minutes! |
203 self._query_cache = TimedCache(self._cache_ttl) |
203 |
204 |
204 def init(self): |
205 def init(self): |
205 """method called by the repository once ready to handle request""" |
206 """method called by the repository once ready to handle request""" |
206 self.info('ldap init') |
207 self.info('ldap init') |
207 # set minimum period of 5min 1s (the additional second is to minimize |
208 # set minimum period of 5min 1s (the additional second is to minimize |
208 # resonnance effet) |
209 # resonnance effet) |
209 self.repo.looping_task(max(301, self._interval), self.synchronize) |
210 self.repo.looping_task(max(301, self._interval), self.synchronize) |
210 self.repo.looping_task(max(7, self._query_cache.ttl.seconds // 10), |
211 self.repo.looping_task(self.cache_ttl // 10, |
211 self._query_cache.clear_expired) |
212 self._query_cache.clear_expired) |
212 |
213 |
213 def synchronize(self): |
214 def synchronize(self): |
214 """synchronize content known by this repository with content in the |
215 """synchronize content known by this repository with content in the |
215 external repository |
216 external repository |