不确定这是否是该问题的最佳标题......也许有人可以为我重命名它?
我的问题是关于在 Redis 的 c# ServiceStack 包装器中读取和组合数据的性能以及调用在内部如何工作。
我将解释两种有望产生最终结果的情景。一种情况是将类别 ID 列表附加到事务,以便可以独立存储类别。
问题:我的最终目标是检索所有具有“食物”类别的交易。
我试图对其他有助于我理解的要点进行编号。考虑有 10,000 笔交易,每笔交易平均有 3 个类别。
注意: ServiceStack.Net Redis中有一个相关问题:Storing Related Objects vs. Related Object Ids但是没有解释效率。
示例 A
public class Transaction
{
public List<string> CategoryIds;
}
示例 B
public class Transaction
{
public List<string> CategoryNames;
}
代码
var transactionClient = redisClient.GetTypedClient<Transaction>();
//1. is this inefficient returning all transactions?
// is there any filtering available at this part?
var allTransactions = transactionClient.GetAll();
//2. In the case of Example A where the categories are stored as id's
// how would I map the categories to a transaction?
// maybe I have a List that has a container with the Transaction associated with a
// list of Categories, however this seems inefficient as I would have to loop
// through all transactions make a call to get their Categories and then
// populate the container datatype.
//3. If we are taking Example B how can I efficiently just retrieve the transactions
// where they have a category of food.