Skip to content

TimeSpan cannot be used for caching. #9612

Closed
@Nokecy

Description

@Nokecy
   public class CacheItem
    {
        public TimeSpan TimeSpan { get; set;}
    }

  [Fact]
        public async Task Test_CacheAsync()
        {
            var cache = GetService<IDistributedCache<CacheItem, string>>();

            var cacheValue = new TimeSpan(10, 10, 10);
            
            await cache.SetAsync("abc", new CacheItem() { TimeSpan = cacheValue });

            var value = await cache.GetAsync("abc");

            value.TimeSpan.ShouldBe(cacheValue);
        }

Use memory cache
The test is Failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions