Hello, in this demo I have the following models:
[Document(StorageType = StorageType.Json, Prefixes = ["Player"])]
public class PlayerEntity
{
[RedisIdField, Indexed] public string UniquePlayerId { get; set; }
// other properties
}
[Document(StorageType = StorageType.Json, Prefixes = ["PlayerState"])]
public class PlayerStateEntity
{
[RedisIdField, Indexed] public string UniquePlayerId { get; set; }
// other properties
}
and two RedisCollection instances:
var provider = new RedisConnectionProvider(redisConfigurationOptions);
provider.Connection.DropIndexAndAssociatedRecords(typeof(PlayerEntity));
await provider.Connection.CreateIndexAsync(typeof(PlayerEntity));
provider.Connection.DropIndexAndAssociatedRecords(typeof(PlayerStateEntity));
await provider.Connection.CreateIndexAsync(typeof(PlayerStateEntity));
var players = provider.RedisCollection<PlayerEntity>();
var playerStates = provider.RedisCollection<PlayerStateEntity>();
any record inserted to the 'playerStates' collection is also included in the 'players' collection when I enumerate it:
await players.InsertAsync(new PlayerEntity
{
UniquePlayerId = Guid.NewGuid().ToString(),
});
await playerStates.InsertAsync(new PlayerStateEntity
{
UniquePlayerId = Guid.NewGuid().ToString(),
});
var playerList = await players.ToListAsync();
Console.WriteLine(playerList2.Count); // Should be 1
The problem seems to happen because "PlayerState" prefix starts with "Player" which is the other prefix. If I change the prefixes to completely different strings the problem is gone. Is this a bug? What are some good strategies to create key prefixes that will not conflict with each other? I have multiple apps that share the same redis instance, I'm thinking about concatenating the application namespace to all key prefixes to try to prevent similar issues. Do you have any better suggestions?
Hello, in this demo I have the following models:
and two RedisCollection instances:
any record inserted to the 'playerStates' collection is also included in the 'players' collection when I enumerate it:
The problem seems to happen because "PlayerState" prefix starts with "Player" which is the other prefix. If I change the prefixes to completely different strings the problem is gone. Is this a bug? What are some good strategies to create key prefixes that will not conflict with each other? I have multiple apps that share the same redis instance, I'm thinking about concatenating the application namespace to all key prefixes to try to prevent similar issues. Do you have any better suggestions?