- cached_state[mac] = ip
- if len(cached_state) > config.config['arper_min_entries_to_be_valid']:
- return cls(cached_state)
- else:
- msg = f'{cache_file} is invalid: only {len(cached_state)} entries. Deleting it.'
- logger.warning(msg)
- warnings.warn(msg, stacklevel=2)
+ state[mac] = ip
+ count += 1
+ else:
+ logger.debug('%s is too stale.', cache_file)
+
+ @classmethod
+ @overrides
+ def load(cls) -> Any:
+ """Internal helper method to fulfull Persistent requirements."""
+
+ local_state: BiDict = BiDict()
+ cache_file = config.config['arper_cache_location']
+ max_staleness = config.config['arper_cache_max_staleness'].total_seconds()
+ logger.debug('Trying to load main arper cache from %s...', cache_file)
+ cls._load_state(cache_file, max_staleness, local_state)
+ if len(local_state) <= config.config['arper_min_entries_to_be_valid']:
+ msg = f'{cache_file} is invalid: only {len(local_state)} entries. Deleting it.'
+ logger.warning(msg)
+ warnings.warn(msg, stacklevel=2)
+ try: