public async Task <ContainerDocumentCacheEntry <T> > GetAsync <T>(string key, CancellationToken token) where T : class, IContainerDocument, new() { var json = await cache .GetStringAsync(key, token) .ConfigureAwait(false); return(ContainerDocumentCacheEntry <T> .Deserialize(json)); }
internal static string Serialize(ContainerDocumentCacheEntry <T> obj) { if (obj is null) { return(null); } return(JsonConvert.SerializeObject(obj)); }
public async Task <ContainerDocumentCacheEntry <T> > SetAsync <T>(string key, ContainerDocumentCacheEntry <T> value, ContainerDocumentCacheEntryOptions options, CancellationToken token) where T : class, IContainerDocument, new() { var json = ContainerDocumentCacheEntry <T> .Serialize(value); await cache .SetStringAsync(key, json, options, token) .ConfigureAwait(false); return(value); }