Search code examples
servicestack.redis

ServiceStack.Redis RedisTypedClient TTL


I'm using ServiceStack.Redis v5.10.4 and trying to set the TTL using the following code:

Note: mClientsManager = IRedisClientsManager ttl = TimeSpan?

await using var client = await mClientsManager.GetClientAsync(token).ConfigureAwait(false);
var typedClient = client.As<Test>();
await typedClient.SetValueAsync(key, value, ttl.Value, token).ConfigureAwait(false);

Reviewing the data in Redis, the TTL is set to -1.

What am I doing wrong?

Just a side note... I used the synchronous method and it works. Also looking at this location, it appears the method is calling the wrong overload... If I'm looking at the right source.

https://github.com/ServiceStack/ServiceStack.Redis/blob/master/src/ServiceStack.Redis/Generic/RedisTypedClient.Async.cs

Any suggestions?


Solution

  • I've just fixed this typed API in this commit. This change is available from the latest v5.10.5 that's now available on MyGet.

    Alternatively you can explicitly change the TTL for a key using this async API:

    await client.ExpireEntryInAsync(key, ttl.Value, token)