I have around 336 keys that i am trying to remove which are SortedSets, i am using BookSleeve as C3 Client with Redis on Ubuntuserver. the code below works, but if i remove the Console.WriteLine it randomly does not delete around 100 keys. it does not throw any error, when i turn on Montior on redis server side i do not see a ZREM statment being sent for those not delete ones from c# side. why would it work with Console.Writeline present and not when it is commented out baffles me. any ideas?
public virtual void RemoveKey(string item, string id)
{
for (int i = 1; i <= item.Length; i++)
{
Console.WriteLine(PrefixKey + item.Substring(0, i));
_redisClient.SortedSets.Remove(_database,
PrefixKey + item.Substring(0, i), id);
}
}
I have a class
public class RedisRepository
{
protected static RedisConnection _redisClient;
protected int _database;
protected bool disposed;
public RedisRepository(int database)
{
string server = ConfigurationManager.AppSettings["redis.server"];
int port = Convert.ToInt32(ConfigurationManager.AppSettings["redis.port"]);
string password = ConfigurationManager.AppSettings["redis.password"];
_redisClient = new RedisConnection(server, port, -1, password);
_database = database;
_redisClient.Open();
}
~RedisRepository()
{
this.Dispose(false);
}
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
_redisClient.CloseAsync(false);
_redisClient.Dispose();
}
// Dispose unmanaged resources here.
}
disposed = true;
}
}
I have inherited above RedisRpository class into another class that uses its _redisClient object.