We noticed a bug in the deletion of list items, more specifically in the RemoveAllFromList method.
The issue can be reproduced with the code below:
using System;
using System.Linq;
using ServiceStack;
using ServiceStack.Redis;
namespace ServiceStackBugs
{
class Program
{
static void Main(string[] args)
{
var host = "localhost";
var db = 15;
var mngr = new BasicRedisClientManager($"{host}?db={db}");
using (var client = mngr.GetClient())
{
Console.Out.WriteLine($"Creating list 'list' with one item");
client.PushItemToList("list", "item");
// does not behave as expected
client.RemoveAllFromList("list");
var items = client.GetAllItemsFromList("list");
var dump = string.Join(", ", items.Select(i => $"'{i}'"));
Console.Out.WriteLine($"Key 'list' contains: {dump}; even though list was cleared");
// works as expected
client.Remove("list");
items = client.GetAllItemsFromList("list");
dump = string.Join(", ", items);
if (items.IsEmpty())
Console.Out.WriteLine($"Key 'list' contains nothing after key deletion");
else
Console.Out.WriteLine($"Key 'list' contains: {dump}, after key deletion");
// and the list with multiple items
Console.Out.WriteLine($"Creating list 'list' with one two items");
client.PushItemToList("list", "item1");
client.PushItemToList("list", "item2");
client.RemoveAllFromList("list");
// works as expected
items = client.GetAllItemsFromList("list");
dump = string.Join(", ", items);
if (items.IsEmpty())
Console.Out.WriteLine($"Key 'list' contains nothing after list was cleared");
else
Console.Out.WriteLine($"Key 'list' contains: {dump}, after list was cleared");
}
Console.ReadLine();
}
}
}