Skip to content

CachedInfluxRepo

Namespace: Database.Repository.InfluxRepo

Cached implementation of InfluxDB repository that buffers writes when InfluxDB is unavailable.
Decorates the base InfluxRepo with write-through caching for data resilience.

public class CachedInfluxRepo : IInfluxRepo

Inheritance ObjectCachedInfluxRepo

Implements IInfluxRepo

Constructors

CachedInfluxRepo(IConfiguration, IMemoryCache, ILogger<CachedInfluxRepo>)

Constructor for the CachedInfluxRepo class.

public CachedInfluxRepo(IConfiguration configuration, IMemoryCache memoryCache, ILogger<CachedInfluxRepo> logger)

Parameters

configuration IConfiguration

Configuration for InfluxDB connection

memoryCache IMemoryCache

Memory cache for buffering failed writes

logger ILogger<CachedInfluxRepo>

Logger instance

Exceptions

ArgumentException

Thrown when InfluxDB configuration is missing

Methods

GetCachedPoints()

Gets all cached PointData objects that failed to write to InfluxDB.
Used by background service for retry operations.

public Dictionary<Object, PointData> GetCachedPoints()

Returns

Dictionary of cache keys and their corresponding PointData objects

GetOutsideWeatherData(DateTime, DateTime, String)

public IAsyncEnumerable<PointDataValues> GetOutsideWeatherData(DateTime start, DateTime end, string place)

Parameters

start DateTime

end DateTime

place String

Returns

IAsyncEnumerable<PointDataValues>

GetSensorWeatherData(DateTime, DateTime)

public IAsyncEnumerable<PointDataValues> GetSensorWeatherData(DateTime start, DateTime end)

Parameters

start DateTime

end DateTime

Returns

IAsyncEnumerable<PointDataValues>

RemoveCachedPoint(Object)

Removes a cached point after successful retry.

public void RemoveCachedPoint(object cacheKey)

Parameters

cacheKey Object

The cache key to remove

WriteOutsideWeatherData(String, String, Double, DateTime, Int32)

public Task WriteOutsideWeatherData(string place, string website, double temperature, DateTime timestamp, int postalcode)

Parameters

place String

website String

temperature Double

timestamp DateTime

postalcode Int32

Returns

Task

WriteSensorData(Double, String, Int64, Int32)

public Task WriteSensorData(double measurement, string sensor, long timestamp, int sequence)

Parameters

measurement Double

sensor String

timestamp Int64

sequence Int32

Returns

Task