public void Persist() { var cacheBits = _tokenCache.Serialize(); Cache = new TokenEntity(userId, cacheBits, DateTime.UtcNow); _repository.InsertOrReplace(Cache); _tokenCache.HasStateChanged = false; }
public void Load() { var latestToken = _repository.GetAllTokensForUser(userId) .OrderByDescending(a => a.LastWrite) .FirstOrDefault(); if (Cache == null || (latestToken != null && Cache.LastWrite < latestToken.LastWrite)) { Cache = latestToken; } _tokenCache.Deserialize((Cache == null) ? null : Cache.CacheBits); }
public void InsertOrReplace(TokenEntity tokenEntity) { var tableOp = TableOperation.InsertOrReplace(tokenEntity); _cloudTable.ExecuteAsync(tableOp).Wait(); }
public void Delete(TokenEntity tokenEntity) { var tableOp = TableOperation.Delete(tokenEntity); _cloudTable.ExecuteAsync(tableOp).Wait(); }