private static CosmosCacheSession BuildCosmosCacheSession(string key, byte[] content, DistributedCacheEntryOptions options, CosmosCacheOptions cosmosCacheOptions)
        {
            DateTimeOffset creationTime = DateTimeOffset.UtcNow;

            DateTimeOffset?absoluteExpiration = CosmosCache.GetAbsoluteExpiration(creationTime, options);

            long?timeToLive = CosmosCache.GetExpirationInSeconds(creationTime, absoluteExpiration, options);

            bool hasSlidingExpiration = timeToLive.HasValue && options.SlidingExpiration.HasValue;

            long?absoluteSlidingExpiration = null;

            if (hasSlidingExpiration && absoluteExpiration.HasValue)
            {
                absoluteSlidingExpiration = absoluteExpiration.Value.ToUnixTimeSeconds();
            }

            return(new CosmosCacheSession()
            {
                SessionKey = key,
                Content = content,
                TimeToLive = timeToLive,
                IsSlidingExpiration = hasSlidingExpiration,
                AbsoluteSlidingExpiration = absoluteSlidingExpiration,
                PartitionKeyAttribute = cosmosCacheOptions.ContainerPartitionKeyAttribute,
            });
        }
        private static CosmosCacheSession BuildCosmosCacheSession(string key, byte[] content, DistributedCacheEntryOptions options, DateTimeOffset?creationTime = null)
        {
            if (!creationTime.HasValue)
            {
                creationTime = DateTimeOffset.UtcNow;
            }

            DateTimeOffset?absoluteExpiration = CosmosCache.GetAbsoluteExpiration(creationTime.Value, options);

            long?timeToLive = CosmosCache.GetExpirationInSeconds(creationTime.Value, absoluteExpiration, options);

            return(new CosmosCacheSession()
            {
                SessionKey = key,
                Content = content,
                TimeToLive = timeToLive,
            });
        }