SHOW:
|
|
- or go back to the newest paste.
1 | - | private Uri GetDocumentUri(string key) |
1 | + | private Uri GetDocumentUri(string key) |
2 | - | { |
2 | + | { |
3 | - | return UriFactory.CreateDocumentUri( |
3 | + | return UriFactory.CreateDocumentUri( |
4 | - | _options.DatabaseName, |
4 | + | _options.DatabaseName, |
5 | - | _options.CollectionName, |
5 | + | _options.CollectionName, |
6 | - | key); |
6 | + | key); |
7 | } | |
8 | - | |
8 | + | |
9 | - | public async Task<byte[]> GetAsync(string key, CancellationToken token) |
9 | + | public async Task<byte[]> GetAsync(string key, CancellationToken token) |
10 | - | { |
10 | + | { |
11 | - | var uri = this.GetDocumentUri(key); |
11 | + | var uri = this.GetDocumentUri(key); |
12 | - | |
12 | + | |
13 | - | try |
13 | + | try |
14 | - | { |
14 | + | { |
15 | - | var result = await _client |
15 | + | var result = await _client |
16 | - | .ReadDocumentAsync<CosmosDbCacheItem>(uri, new RequestOptions() { }); |
16 | + | .ReadDocumentAsync<CosmosDbCacheItem>(uri, new RequestOptions() { }); |
17 | - | |
17 | + | |
18 | - | return result.Document.ToByteContent(); |
18 | + | return result.Document.ToByteContent(); |
19 | - | } |
19 | + | } |
20 | - | catch (DocumentClientException) |
20 | + | catch (DocumentClientException) |
21 | - | { |
21 | + | { |
22 | - | return null; |
22 | + | return null; |
23 | - | } |
23 | + | } |
24 | } |