protected virtual async Task SetContentToCacheAsync( ZeusCachingContext context, ZeusCachingProfileOptions options, string key, object content, ICachingAdapter cachingAdapter) { object wrappedContent; if (options.WrappingResultHandler != null) { wrappedContent = options.WrappingResultHandler(_serviceProvider, context.ExecutionContext.HttpContext, content); } else { wrappedContent = content; } if (wrappedContent is string) { await cachingAdapter.SetContentAsync(key, (string)wrappedContent, context.SlidingExpiration, null, context.AbsoluteExpirationRelativeToNow); } else { // Serialize the response var json = Serializer(wrappedContent); await cachingAdapter.SetContentAsync(key, json, context.SlidingExpiration, null, context.AbsoluteExpirationRelativeToNow); } }
public Task SetContentAsync( string key, string content, TimeSpan?slidingExpiration = null, DateTimeOffset?absoluteExpiration = null, TimeSpan?absoluteExpirationRelatedToNow = null, CancellationToken cancellationToken = default) { return(_adapter.SetContentAsync(key, content, slidingExpiration, absoluteExpiration, absoluteExpirationRelatedToNow, cancellationToken)); }