简体   繁体   English

Redis 多表?

[英]Redis multiple tables?

I have a use case where I have to search by key and in another use case, I have to search by value.我有一个用例,我必须按键搜索,而在另一个用例中,我必须按值搜索。 Given this scenario, what's the best approach as scanning the entire cache can degrade performance (to filter by value).在这种情况下,扫描整个缓存的最佳方法是什么会降低性能(按值过滤)。

  1. Do reverse store ie store value as key and key as the value in the same logical table?是否反向存储,即在同一个逻辑表中存储值作为键和键作为值?
  2. Use different database and store Value, Key as K |使用不同的数据库并将Value、Key存储为K | V. I see a few posts that suggest using a different database is a bad idea and deprecated? V. 我看到一些帖子建议使用不同的数据库是一个坏主意并且已弃用?

Or is there a better alternative/approach?还是有更好的选择/方法?

Do you really need to use Redis?你真的需要使用Redis吗? Redis (and generally key-value stores) are not optimized for this kind of task. Redis(通常是键值存储)没有针对此类任务进行优化。

If you need to stick with Redis you can create index to implement search by value.如果您需要坚持使用 Redis,您可以创建索引以实现按值搜索。 It will not be as storage effective and intuitive as eg SQL database table though.它不会像 SQL 数据库表那样存储有效和直观。 See documentation here: https://redis.io/topics/indexes请参阅此处的文档: https://redis.io/topics/indexes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM