D
D
Denis2018-09-08 11:13:21
Redis
Denis, 2018-09-08 11:13:21

Storing table of active orders in radish?

Hello.
There are orders that are active for 30 minutes to 4 hours.
There are already 500,000 orders in the database today.
The server is directly accessed 1000 requests per minute
Basically the request is, are there any new orders for me?
There are always about 300-500 orders online . I
use Laravel
Now all queries go directly to Mysql, but in fact, why load the database with such frequent queries? Here I want to use Redis for this.
In general, it handles this kind of flow just fine, but I mostly use it as a key=>value.
Redis still has other data types, so I actually wanted to know how to make a list of 300 lines with unique keys.
i.e. even if it’s elementary, it would be possible just to drive an array of all active orders into one key orders and everything is fine, but the question arises, in order to remove 1 order from the array, you need to sort through it all and write back a new array without this order. Likewise with additions.
Is it possible to simply add to the array with 1 command and delete the same by key, plus get the entire list if necessary. It will also be a plus, a selection according to the criteria

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
Timur, 2018-09-08
@XAKEPEHOK

But we recently took a radish and poheril a good half of the keys. Just took it at night and fucked it up. Randomly different keys. This is the first time in 5 years that we have done this. Backup - yes, there is, but this is already a loss of consistency. After this incident, I cut myself on the nose that I store there only those data that are permissible to lose or can be restored without much loss.

D
D', 2018-09-08
@Denormalization

Redis has HSET/HGET/HDEL commands .
They are perfect for this task.
There is a possibility to "add to the array with 1 command and delete by the same key, plus get the whole list if necessary".

  • HSET - set the desired value in the list
  • HGET - will return the desired value from the list
  • HDEL - remove the desired value from the list
  • HGETALL - will return all values ​​in the list

K
Kekoc, 2018-09-08
@Kekoc

If there are requests to the database by key, then such a number does not particularly load it. But with radish, the idea is also OK, but not a cool performance gain.

I
iStorm, 2018-09-09
@iStorm

If you build covering indexes in MySQL, it will work about the same as radish in terms of speed, and reliability will be higher.
And why do you keep the old ones if they are no longer used?
Upload to the archive and ideas with radishes will disappear)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question