Answer the question
In order to leave comments, you need to log in
How justified is it to transfer user data from php to a node via memcash?
Good afternoon.
The situation is this, PHP generates a token for the user, which is written to the database. The main information for user authentication in the node is the id + token. They are sent along with the connection to socket.io (takes from the handshake) and, accordingly, the node crawls into the database to check whether there is such a user at all and what rights or data he has.
There was an idea to simply store an array of users already in the node itself, creating just an array and after each call to the database, hammer this array with information about users. But then the node itself will turn into a database and I don’t see the opportunity to update this information when executing a PHP script from users (for example, to ban).
Well, a question from the subject. How justified is it to transfer user data from php to a node via memcash? Or is it easier to leave the connection to the database?
Most format requests:
SELECT `name`,`age`,`something`
FROM `users`
INNER JOIN `more info` on (`id`=`id`)
...
WHERE `id`=1 AND `token`='fsdjfkkasfhklasdjfhlkasdfjhalsdk' LIMIT 1
Answer the question
In order to leave comments, you need to log in
If the question is theoretical, then Memcache is faster than Mysql.
If practical, then with the right business architecture, you will hardly notice the difference in speed. Working with Mysql is easier and more reliable.
I would still cache logins and passwords in the node itself after accessing the database. And about updating the password or banning the user - push this information from PHP directly to Node using https://github.com/Wisembly/elephant.io . But this optimization can be left for later. For now, make a working prototype without caching with a query to the database for each connection.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question