public async Task <string> GetAsync(string clientId, string key) { var semaphore = new SemaphoreSlim(1, 1); key = await MakeBlobKey(clientId, key); semaphore = _locks.GetOrAdd(key, semaphore); await semaphore.WaitAsync(); try { var keyExists = await _storage.HasBlobAsync(BlobContainer, key); if (keyExists) { return(await _storage.GetAsTextAsync( BlobContainer, key)); } else { throw new KeyNotFoundException(); } } finally { semaphore.Release(); } }
public async Task <string> Get(string transactionId) { if (await _storage.HasBlobAsync(BlobContainer, GetKey(transactionId))) { return(await _storage.GetAsTextAsync(BlobContainer, GetKey(transactionId))); } return(null); }
public async Task <string> GetTransaction(Guid operationId, string hash, TransactionBlobType type) { var key = GenerateKey(operationId, hash, type); if (await _blobStorage.HasBlobAsync(BlobContainer, key)) { return(await _blobStorage.GetAsTextAsync(BlobContainer, key)); } return(null); }
public async Task <string> GetContentAsync(string messageId) { bool exists = await _blobStorage.HasBlobAsync(ContainerName, messageId); if (!exists) { return(null); } return(await _blobStorage.GetAsTextAsync(ContainerName, messageId)); }
public async Task <BlockchainIndexationState> GetOrCreateAsync() { if (await _blobStorage.HasBlobAsync(Container, DataKey)) { var stateJson = await _blobStorage.GetAsTextAsync(Container, DataKey); return(BlockchainIndexationState.Restore ( JsonConvert.DeserializeObject <IEnumerable <BlockIntervalIndexationState> >(stateJson) )); } else { return(BlockchainIndexationState.Create()); } }
public async Task <List <T> > LoadClientStateAsync(string filename) { try { bool blobExists = await _blobStorage.HasBlobAsync(_container, filename); if (!blobExists) { return(null); } string json = await _blobStorage.GetAsTextAsync(_container, filename); var result = json.DeserializeJson <List <T> >(); return(result ?? new List <T>()); } catch (Exception exc) { _log.Error(exc); throw; } }
private async Task <Templates> GetAllTemplates() { Templates record; if (!_memoryCache.TryGetValue(TemplatesCacheKey, out record)) { if (!await _blobStorage.HasBlobAsync(ContainerName, TemplatesFile)) { return(null); } record = (await _blobStorage.GetAsTextAsync(ContainerName, TemplatesFile)).DeserializeJson <Templates>(); var cacheEntryOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(_cacheExpTime); _memoryCache.Set(TemplatesCacheKey, record, cacheEntryOptions); } return(record); }
public async Task <string> GetAsTextAsync(string container, string key) => await WrapAsync(async() => await _impl.GetAsTextAsync(container, key), container);
public async Task <string> GetAsTextAsync(string container, string key) => await _retryService.RetryAsync(async() => await _impl.GetAsTextAsync(container, key), _onGettingRetryCount);
protected async Task <string> GetBlobStringAsync(string blobKey) { return(await Storage.GetAsTextAsync(_container, blobKey)); }