'How to set sliding expiration for HashSet using ConnectionMultiplexer of StackExchange.Redis lib

We are storing a list of properties in the Hash Set as shown in the following code

HashEntry[] snippetProepries = {
                                    new HashEntry("properties", JsonSerializer.Serialize(propertyModelList)),
                                    new HashEntry("created_at", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"))
                                };
redisCache.HashSet(claimsSnippetId, snippetProepries);

There is an option to set the Expiration using redisCache.KeyExpire(claimsSnippetId, TimeSpan.FromHours(24));, but it seems it's of absolute type.

How I can set Sliding expiration for the HashSet in my case?

Thanks, Saurabh



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source