M
M
Michail Wowtschuk2016-12-26 19:54:02
MySQL
Michail Wowtschuk, 2016-12-26 19:54:02

How to make a task queue for inserting data into a database?

Hello everyone, can you explain how to create a task queue for inserting data into a database? Preferably with simple examples.
Are there any differences between working with Mysql and Redis databases?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel, 2016-12-26
@electronik777

Do you mean queue? But what if you need to access data that has not yet been inserted? Well, there are transactions, for most cases.

V
Vitaly, 2016-12-26
@vitali1995

For the task queue, I recommend RabbitMQ, there are enough examples.
Comparing Mysql and Redis does not seem reasonable, they work in completely different ways.

R
Roman Mirilaczvili, 2016-12-29
@2ord

Redis: LPUSH + BRPOP
fiznool.com/blog/2016/02/24/building-a-simple-mess...
For lazy insertion into mySql, the write data (attributes) by the webserver process is placed in the Redis queue:
LPUSH queue1 '{ "name":"Kolya","age":25}'
Another process periodically checks the length of the queue, and if it is non-zero, it takes the
BRPOP queue1 element from the queue
and, extracting data from JSON, composes a query for insertion into mySql:
INSERT INTO tbl_name ( name, age) VALUES('Kolya', 25)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question