K
K
Khomedov2018-08-27 08:50:51
PHP
Khomedov, 2018-08-27 08:50:51

User DB in Redis?

Hello everyone, how to store user registration data in Redis?
The user database is stored in Redis.
The following fields are stored for each user:
Id
name
email
password_hash
It is necessary to authorize the user by email and password (for a combination of email, password_hash get user data).
functions in php:

/**
 * Creates new user
 *
 * @param array $user_data          User data contains the following fields:
 *                                      - name
 *                                      - email
 *                                      - password_hash
 *
 * @return string                   Returns ID of created user
 *
 * @throws \UserExistsException     Throws exception if user with this email already exists
 *
 */
function create_user(array $user_data)
{
    // your code here
}

/**
 * Finds user by combination of email and password hash
 *
 * @param string $email
 * @param string $password_hash
 *
 * @return string|null                   Returns ID of user or null if user not found
 */
function authorize_user($email, $password_hash)
{
    // your code here
}

I know how to make a form and send data to PHP functions, but I don’t understand how to store data in Redis

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mysterion, 2018-08-27
@Mysterion

Just like in any other database.
Look for a class for working with Redis in PHP and fasten it to get records from the database and add them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question