To make use of Redis for session administration in Magento 2, you’ll must configure Magento to make the most of Redis because the session storage backend. Right here’s a step-by-step information on find out how to set it up
Set up Redis
Be sure to have Redis put in and working in your server or native setting. You may obtain Redis from the official web site and comply with the set up directions on your working system.
Configure Magento 2 to make use of Redis for session storage:
1. Log in to your Magento 2 server or entry the Magento 2 codebase.
2. Within the Magento 2 root listing, open the `app/and many others/env.php` file.
3. Find the `session` configuration part, which ought to appear like this:
'session' => [ 'save' => 'files', 'save_path' => 'path/to/session/files', ]
4. Exchange the ‘save‘ worth with ‘redis‘ and add a ‘redis‘ key to the ‘session‘ array with the Redis server configuration:
'session' => [ 'save' => 'redis', 'redis' => [ 'host' => '127.0.0.1', 'database' => '2', 'log_level' => '4', 'port' => '6379', 'password' => '', 'timeout' => '2.5', 'persistent_identifier' => '', 'compression_threshold' => '2048', 'compression_library' => 'gzip', 'max_concurrency' => '6', 'break_after_frontend' => '5', 'break_after_adminhtml' => '30', 'first_lifetime' => '600', 'bot_first_lifetime' => '60', 'bot_lifetime' => '7200', 'disable_locking' => '0', 'min_lifetime' => '60', 'max_lifetime' => '2592000', 'sentinel_master' => '', 'sentinel_servers' => '', 'sentinel_connect_retries' => '5', 'sentinel_verify_master' => '0' ] ]
5. Save the modifications to the `env.php` file.
Clear Magento cache: Clear the Magento cache to make sure the brand new session configuration takes impact. You are able to do this by working the next command from the Magento root listing:
php bin/magento cache: clear
Magento Firm ? Learn Extra
Check session administration with Postman:
1. Open Postman or any REST API testing instrument.
2. Set the HTTP technique to POST.
3. Set the URL to your Magento 2 base URL adopted by
/relaxation/V1/integration/admin/token (e.g., `http://yourmagento2domain.com/relaxation/V1/integration/admin/token
).`form-data` and add the next key-value pairs:
4. Within the request physique, choose
`username`: Your Magento 2 admin username
`password`: Your Magento 2 admin password
5. Click on the “Ship” button to ship the request. This may return an entry token.
6. Copy the entry token from the response.
1. Set the HTTP technique to GET.
2. Set the URL to your Magento 2 base URL adopted by /relaxation/V1/retailer/storeViews.
3. Add a header with the next key-value pair:
: Bearer [access_token]`[access_token]` with the entry token you obtained within the earlier step.
d. Click on the “Ship” button to ship the request. This may retrieve the shop views info.
Redis monitor command (When you use Redis for session storage, you’ll see output just like the next)
Redis ping command
PONG must be the response.
redis-cli command reference
That’s it! You might have now configured Redis for session administration in Magento 2 and examined it utilizing Postman. You may proceed exploring different Magento 2 REST APIs utilizing the entry token and acceptable endpoints.