Search code examples
servicestackservicestack.redis

Service.Redis Trimming a list


Following tutorials that is using ServiceStack v3 and stuck at when trying to trim a list in V4.

What is the equivalent in V4? Trying to google examples but with no luck.


Solution

  • You can just use TrimList, e.g:

    redis.TrimList(listId, keepStartingFrom, keepEndingAt);
    

    Or you can use Trim() off IList, e.g:

    redis.Lists[listId].Trim(keepStartingFrom, keepEndingAt);
    

    Both TrimList() and IRedisList.Trim() also have Redis Typed Client API versions:

    redis.As<Poco>().TrimList(listId, keepStartingFrom, keepEndingAt);
    redis.As<Poco>().Lists[listId].Trim(keepStartingFrom, keepEndingAt);