0

we are trying to move our database from MySQL. We are trying to understand how Redis work and we would like to know the best solution for this example.

enter image description here

How to solve Product->Categories relation?

We will need - list of all products sorted by ID

  • list of all products sorted by Name (ASC / DESC)

  • list of all products in Category 1

  • list of all products in Category 1 sorted by Name / ID / (ASC / DESC)

From second part of image we will need to filter by Attributes

  • list of all products with Attribute 1 (Attribute Value 1)

  • list of all products with Attribute 1 (Attribute Value 1) in Category 1 sorted by Name

Is it good to use Redis for this kind of data?

Thanks

Rastislav
  • 55
  • 9

1 Answers1

0

Of course you could use Redis for this kind of data. But it would be different from using a relational database!

The answer would be to use sets, as discussed in this post: how to have relations many to many in redis

But before you actually move to Redis, please consider what problem you're trying to solve. MySQL is pretty decent as a database nowadays and it has 'schemaless/NoSQL' like functionality using JSON documents. It sounds like you're just in the process of exploring what you could do with Redis. While I think Redis is a very nice product, and you should really try it out, please also consider continue using MySQL making use of its more modern features.

Community
  • 1
  • 1
MichielB
  • 4,181
  • 1
  • 30
  • 39
  • In global we are working on mobile application which will be connected to Magento store. Magento REST API is too slow and their database is too heavy so we are going to create middleware for faster responses to application. We need to store in middleware Products, Categories, Attributes of products. Than we need to create responses for filter requests. Our middleware will work like cache. It should be as fast as possible. – Rastislav Aug 26 '16 at 11:45
  • Great! Redis is crazy fast, but MySQL can also be. Maybe the Magento queries are just not so good. See http://blog.ulf-wendel.de/2013/using-phps-memcache-interface-to-query-mysql-5-7/ - and I do agree Redis is very well suited for a cache. If you do caching, you might want to consider to cache the denormalized version - caching the complete product with all its categories, and the complete category with all its products, and simply replacing it whenever it is updated, instead of re-creating the N-M relation. – MichielB Aug 26 '16 at 12:00
  • Yes it would be great to have all list directly in Redis but there is a lot of combination connected with filters. Category is like one attribute but product can have size, color, price... and you can use multiple filters = a lot of combinations... – Rastislav Aug 26 '16 at 12:06