redis - How to keep sql tables in redis efficiently
问题描述
I searched on net but couldnt find any brieny description for it, so here its;
There is Products
table, here is the example of 2 rows;
ID Name Price Expire CreatedDate ...
1 A 12 4 01.01.2019
2 B 25 5 01.01.2019
there is 100 million more which needed to be searched and retrieve fast.
What I learn with some search Redis keeps data as JSON,
so I create a key composite of tablename:row_primary_key
and write this 100 million rows from database to redis with keys as(and value is entire row serialized json string)
Products:1
Products:2
...
So I am able to get any particular row with key, but I think you asked the question at the moment what if I need make search with other columns, for example Price or Name?
What first thing to come in mind generate another 100 million in Redis with keys composite of 'tablename:price' but it sounds extremely frustrating and waste of memory(I don't say even when there is 10 more columns suppose to be in search).
So whats the best and most efficient way to store rows from SQL table in Redis?
And I am using StackExchange.Redis library.
解决方案
推荐阅读
- windows-10 - 在 Spring Tool Suite 4 for Windows 中安装 Lombok
- jquery - onsubmit 确认返回 false 时如何防止表单操作?
- python - Python 正则表达式转义运算符 \ 在替换和原始字符串中
- c++ - 我可以简化这个 std::list 的数量吗?
- python - 获得k-倒数最近邻
- python - 在 PonyORM 中找不到反向属性
- javascript - 如何使用 chat.postmessage 作为工作区用户发布松弛消息?
- asp.net - 根据某些条件更改网格视图值
- javascript - React native 不能通过命令在 ios 中运行,但可以在 Xcode 中运行?
- javascript - 在 Angular 组件类中调用自定义 jQuery 函数