php_admin_value[session.save_handler] = redis
php_admin_value[session.save_path] = "tcp://127.0.0.1:6379?persistent=1&weight=1&database=2"
There is link https://github.com/phpredis/phpredis#php-session-handler for save_path parameters
The checking script is
<?php
$redisinstance = new Redis();
$redisinstance->connect("127.0.0.1", 6379);
$result = $redisinstance->get("test");
if ($result) {
echo $result;
} else {
echo "No matching key found. Refresh the browser to add it!";
$redisinstance->set("test", "Successfully retrieved the data!") or die("Couldn't save anything to redis...");
}
?>
After refreshing page
redis-cli
127.0.0.1:6379> select 0
OK
127.0.0.1:6379> keys "*"
1) "test"
127.0.0.1:6379> get "test"
"Successfully retrieved the data!"
Page caching
bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=127.0.0.1 --cache-backend-redis-db=0
We saved default values for these options: amqp-host, amqp-port, amqp-user, amqp-password, amqp-virtualhost, amqp-ssl, amqp-ssl-options.
bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=127.0.0.1 --page-cache-redis-db=1
bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=127.0.0.1 --page-cache-redis-db=1
We saved default values for these options: amqp-host, amqp-port, amqp-user, amqp-password, amqp-virtualhost, amqp-ssl, amqp-ssl-options.
Session caching
bin/magento setup:config:set --session-save=redis --session-save-redis-host=127.0.0.1 --session-save-redis-log-level=3 --session-save-redis-db=2
Overwrite the existing configuration for session-save?[Y/n]y
We saved default values for these options: amqp-host, amqp-port, amqp-user, amqp-password, amqp-virtualhost, amqp-ssl, amqp-ssl-options.
We saved default values for these options: amqp-host, amqp-port, amqp-user, amqp-password, amqp-virtualhost, amqp-ssl, amqp-ssl-options.
Checking
redis-cli monitor
After refreshing shop page
where 0, 1, 2 are redis databses in [0 127.0.0.1:59236], 1 127.0.0.1:59240], [2 127.0.0.1:59428] rows.
How to flush redis databases
redis-cli FLUSHALL
flush all databases
redis-cli -n <database number> FLUSHDB
flush specific database
How to show keys and flush current database
redis-cli127.0.0.1:6379> select 2
OK
127.0.0.1:6379[2]> keys "*"
1) "PHPREDIS_SESSION:rd2hma5hltcmlq8gokto58nutm"
127.0.0.1:6379[2]> flushdb
OK
127.0.0.1:6379[2]> keys "*"
(empty list or set)
127.0.0.1:6379[2]> keys "*"
(empty list or set)
Комментариев нет:
Отправить комментарий