RemoveItemFromSet() method not working with C# IRedisTypedClient

This code snippet shows what I am trying to accomplish, but it doesn’t work. The items are not removed. Any hints why?

IRedisTypedClient client = RedisUpdateClient.As();
IRedisSet set = client.Sets[“SCQG0010:SRCR”];

        QualifierGroupsAndValues itemToRemove = set.Where(a => a.QualGroupGuid == "459B2A77-88FD-4F82-8B24-0E9B4FE8F747").FirstOrDefault();
        client.RemoveItemFromSet(set, itemToRemove);

Thanks, Ryan

Sorry - some things didn’t copy correctly. Typed item below is QualfierGroupsAndValues.

IRedisTypedClient<> client = RedisUpdateClient.As<>();
IRedisSet set = client.Sets[“SCQG0010:SRCR”];

QualifierGroupsAndValues itemToRemove = set.Where(a => a.QualGroupGuid == “459B2A77-88FD-4F82-8B24-0E9B4FE8F747”).FirstOrDefault();
client.RemoveItemFromSet(set, itemToRemove);

Assuming that itemToRemove results in an item? is that correct? The item stored has to have the same exact serialized value for redis to recognize it as an item in the SET. Is there anything about the QualifierGroupsAndValues type that serializing it again wouldn’t have the same serialized value. I’m assuming you used the Redis Client to add the item in the set?

Yes, itemToRemove is an item and shows up in the debugger. And yes I used the Redis client to add it to the set originally. It was not updated after the original write to the Redis cache. Should I consider using the toJSon() method to compare them at the time of the write and then at the time of retrieval?

Yeah I’d look at using the string IRedisClient API that way you can remove the item’s original string value, something like:

var items = RedisUpdateClient.GetAllItemsFromSet("SCQG0010:SRCR");
foreach (var item in items) {
    var dto = item.FromJson<QualifierGroupsAndValues>();
    if (dto.QualGroupGuid == "459B2A77-88FD-4F82-8B24-0E9B4FE8F747") {
        RedisUpdateClient.RemoveItemFromSet("SCQG0010:SRCR", item);
        break;
    }
}

mythz,

That worked! Many thanks!

Ryan