+ state[mac] = ip
+ count += 1
+ else:
+ logger.debug('%s is too stale.', cache_file)
+
+ @classmethod
+ @overrides
+ def load(cls) -> Any:
+ 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:
+ os.remove(cache_file)
+ except Exception:
+ pass
+
+ supplimental_state: BiDict = BiDict()
+ cache_file = config.config['arper_supplimental_cache_location']
+ max_staleness = config.config['arper_cache_max_staleness'].total_seconds()
+ logger.debug('Trying to suppliment arper state from %s', cache_file)
+ cls.load_state(cache_file, max_staleness, supplimental_state)
+ if len(local_state) > 0:
+ return cls(local_state, supplimental_state)