/// <summary> /// Public constructor, initializing the eviction thread with the default <see cref="TimeEvictionStrategy"/> /// and <see cref="SpaceEvictionStrategy"/> strategies. /// </summary> /// <param name="logger">Logger to write some debug output</param> /// <param name="beaconCache">The Beacon cache to check if entries need to be evicted</param> /// <param name="configuration">Beacon cache configuration</param> /// <param name="timingProvider">Timing provider required for time retrieval</param> internal BeaconCacheEvictor(ILogger logger, IBeaconCache beaconCache, IBeaconCacheConfiguration configuration, ITimingProvider timingProvider) : this(logger, beaconCache) { strategies = new IBeaconCacheEvictionStrategy[] { new TimeEvictionStrategy(logger, beaconCache, configuration, timingProvider, () => IsShutdownRequested), new SpaceEvictionStrategy(logger, beaconCache, configuration, () => IsShutdownRequested) }; }
private SpaceEvictionStrategy CreateSpaceEvictionStrategyWith(IBeaconCacheConfiguration config) { return(new SpaceEvictionStrategy( mockLogger, mockBeaconCache, config, isShutdownFunc )); }
internal TimeEvictionStrategy(ILogger logger, IBeaconCache beaconCache, IBeaconCacheConfiguration configuration, ITimingProvider timingProvider, Func <bool> isShutdownFunc) { this.logger = logger; this.beaconCache = beaconCache; this.configuration = configuration; this.timingProvider = timingProvider; this.isShutdownFunc = isShutdownFunc; LastRunTimestamp = -1; }
/// <summary> /// Constructor. /// </summary> /// <param name="logger">instance implementing the <see cref="ILogger"/> interface for writing some useful debug messages.</param> /// <param name="beaconCache">The beacon cache to evict if necessary.</param> /// <param name="configuration"></param> /// <param name="isShutdownFunc">a callback function deciding if the eviction strategy should stop execution or not.</param> internal SpaceEvictionStrategy(ILogger logger, IBeaconCache beaconCache, IBeaconCacheConfiguration configuration, Func <bool> isShutdownFunc) { this.logger = logger; this.beaconCache = beaconCache; this.configuration = configuration; this.isShutdownFunc = isShutdownFunc; }
private TimeEvictionStrategy CreateTimeEvictionStrategyWith(IBeaconCacheConfiguration config) { return(new TimeEvictionStrategy( mockLogger, mockBeaconCache, config, mockTimingProvider, isShutdownFunc )); }