public async Task UpdateADRTable(string devEUI, LoRaADRTable table) { using (var redisLock = new RedisLockWrapper(devEUI, this.redisCache)) { if (redisLock.TakeLock()) { 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 (redisLock.TakeLock()) { 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 (redisLock.TakeLock()) { 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> AddTableEntry(LoRaADRTableEntry entry) { LoRaADRTable table = null; using (var redisLock = new RedisLockWrapper(entry.DevEUI, this.redisCache)) { if (redisLock.TakeLock()) { var entryKey = GetEntryKey(entry.DevEUI); table = await this.GetADRTableCore(entryKey) ?? new LoRaADRTable(); AddEntryToTable(table, entry); // update redis store this.redisCache.StringSet(entryKey, JsonConvert.SerializeObject(table)); } } return(table); }