public async Task <LoRaADRTable> AddTableEntry(LoRaADRTableEntry entry) { if (entry is null) { throw new ArgumentNullException(nameof(entry)); } LoRaADRTable table = null; using (var redisLock = new RedisLockWrapper(entry.DevEUI, this.redisCache)) { if (await redisLock.TakeLockAsync()) { var entryKey = GetEntryKey(entry.DevEUI); table = await GetADRTableCore(entryKey) ?? new LoRaADRTable(); AddEntryToTable(table, entry); // update redis store _ = await this.redisCache.StringSetAsync(entryKey, JsonConvert.SerializeObject(table)); } } return(table); }
public async Task UpdateADRTable(DevEui devEUI, LoRaADRTable table) { using var redisLock = new RedisLockWrapper(devEUI, this.redisCache); if (await redisLock.TakeLockAsync()) { _ = await this.redisCache.StringSetAsync(GetEntryKey(devEUI), JsonConvert.SerializeObject(table)); } }
public async Task <bool> Reset(string devEUI) { using (var redisLock = new RedisLockWrapper(devEUI, this.redisCache)) { if (await redisLock.TakeLockAsync()) { return(await this.redisCache.KeyDeleteAsync(GetEntryKey(devEUI))); } } return(false); }
public async Task <LoRaADRTable> GetADRTable(string devEUI) { using (var redisLock = new RedisLockWrapper(devEUI, this.redisCache)) { if (await redisLock.TakeLockAsync()) { return(await this.GetADRTableCore(GetEntryKey(devEUI))); } } Logger.Log(devEUI, "Failed to acquire ADR redis lock. Can't deliver ADR Table", LogLevel.Error); return(null); }
public async Task <LoRaADRTable> GetADRTable(DevEui devEUI) { using (var redisLock = new RedisLockWrapper(devEUI, this.redisCache)) { if (await redisLock.TakeLockAsync()) { return(await GetADRTableCore(GetEntryKey(devEUI))); } } this.logger.LogError("Failed to acquire ADR redis lock. Can't deliver ADR Table"); return(null); }