Esempio n. 1
0
        public async Task UpdateBalanceAsync(string walletId, string assetId, decimal balance, decimal reserved,
                                             long updateSequenceNumber, DateTime?timestamp)
        {
            var wallet = CachedWalletModel.Create(assetId, balance, reserved, timestamp);

            var updated = await _repository.UpdateBalanceAsync(walletId, wallet, updateSequenceNumber);

            if (updated)
            {
                var cacheKey = GetCacheKey(walletId);
                try
                {
                    if (await _redisDatabase.KeyExistsAsync(cacheKey))
                    {
                        await _redisDatabase.TryHashSetAsync(
                            cacheKey,
                            assetId,
                            wallet,
                            _cacheExpiration,
                            _log);
                    }
                }
                catch (RedisConnectionException ex)
                {
                    _log.Warning("Redis cache is not available", ex);
                }
            }
        }
Esempio n. 2
0
 public async Task <IWallet> GetAsync(string walletId, string assetId)
 {
     return(await _redisDatabase.TryHashGetAsync(
                GetCacheKey(walletId),
                assetId,
                async() => CachedWalletModel.Create(await _repository.GetAsync(walletId, assetId)),
                async() => await ReloadAllAsync(walletId),
                _cacheExpiration,
                _log));
 }